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
using namespace std; int n; int ar[100005]; int ar_2[100005]; int dp[100005][2]; int rec(int pos, int side){ if(pos==n){ return 0; } if(dp[pos][side]!= -1){ return dp[pos][side]; } int result=0; if(pos + 1 < n) { if(side==0){ if(ar[pos]<=ar[pos+1]){ result=max(result, rec(pos+1, 0) + 1) ; } if(ar[pos]<=ar_2[pos+1]){ result=max(result, rec(pos+1, 1) + 1); } } if(side==1){ if(ar_2[pos]<=ar_2[pos+1]){ result=max(result, rec(pos+1, 1) + 1); } if(ar_2[pos]<=ar[pos+1]){ result=max(result, rec(pos+1, 0) + 1); } } } return dp[pos][side]=result; } int main() { ios_base::sync_with_stdio(false); cin>>n; for(int i=0; i
>ar[i]; } for(int i=0; i
>ar_2[i]; } multiset
m; memset(dp, -1, sizeof dp); 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)