Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
//#include
#include
#include
#include
#include
#define MOD 1000000007 #define ll long long using namespace std; int n; int arr1[100005]; int arr2[100005]; int memo[100005][2]; int dp (int at, int where){ if(at==n){ return 0; } if(memo[at][where] != -1) return memo[at][where]; int res=0; if(where == 0 and at+1
=arr1[at]){ res = max(res,dp(at+1,0)+1); } if(arr2[at+1]>=arr1[at]){ res = max(res,dp(at+1,1)+1); } } else if(where == 1 and at+1
=arr2[at]){ res = max(res,dp(at+1,1)+1); } if(arr1[at+1]>=arr2[at]){ res=max(res,dp(at+1,0)+1); } } return memo[at][where] = res; } int main() { cin >> n; for(int i =0;i
> arr1[i]; } for(int i = 0;i
> arr2[i]; } memset(memo, -1, sizeof memo); int res = 0; for(int i= 0;i
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)