Submission #1013898

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10138982024-07-04 07:56:52BaytoroBuilding 4 (JOI20_building4)C++17
100 / 100
184 ms58704 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define int ll
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
int n,m;
const int N=1e6+5;
pair<int,int> dp[N][2];
void solve() {
int n;cin>>n;
vector<int> a(2*n+1),b(2*n+1);
for(int i=1;i<=2*n;i++) cin>>a[i];
for(int i=1;i<=2*n;i++) cin>>b[i];
for(int i=1;i<=2*n;i++) dp[i][0]=dp[i][1]={-1,-1};
dp[1][0]={1,1};
dp[1][1]={0,0};
for(int i=2;i<=2*n;i++) {
if(a[i]>=a[i-1] && dp[i-1][0].fr!=-1) {
if(dp[i][0].fr==-1) {
dp[i][0].fr=dp[i-1][0].fr+1;
dp[i][0].sc=dp[i-1][0].sc+1;
}
else {
dp[i][0].fr=min(dp[i][0].fr,dp[i-1][0].fr+1);
dp[i][0].sc=max(dp[i][0].sc,dp[i-1][0].sc+1);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...