Submission #489379

#TimeUsernameProblemLanguageResultExecution timeMemory
489379bigDuckCollecting Stamps 3 (JOI20_ho_t3)C++14
15 / 100
6 ms1484 KiB
#include<bits/stdc++.h> using namespace std; #define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define mp make_pair #define pb push_back #define ft first #define sc second #define ll long long #define pii pair<int, int> #define count_bits __builtin_popcount #define int ll int n, l, x[201], t[201]; pii mom[205][205][2]; int32_t main(){ INIT cin>>n>>l; for(int i=1; i<=n; i++){ cin>>x[i]; } for(int i=1; i<=n; i++){ cin>>t[i]; } pii hlt={-1, -1}; for(int i=0; i<=(n+1); i++){ for(int j=0; j<=(n+1); j++){ mom[i][j][0]=mom[i][j][1]={-1, -1}; } } mom[n+1][0][0]=mom[n+1][0][1]={0, 0}; x[n+1]=l; //0-dreapta, 1-stanga int res=0; for(int i=(n+1); i>=1; i--){ for(int j=0; j<i; j++){ mom[i][j][0]=max(mom[i][j][0], {mom[i][j][1].ft, -(-mom[i][j][1].sc+l-x[i]+x[j] ) } ); int cnt=mom[i][j][0].ft, ac=-mom[i][j][0].sc; if(cnt>=0){ res=max(res, cnt); for(int k=j+1, ac2=ac; k<i; k++){ ac2+=x[k]-x[k-1]; if(ac2<=t[k]){ mom[i][k][0]=max(mom[i][k][0], {cnt+1, -ac2}); } else{ mom[i][k][0]=max(mom[i][k][0], {cnt, -ac2}); } } } mom[i][j][1]=max(mom[i][j][1], {mom[i][j][0].ft, -(-mom[i][j][0].sc+x[j]+l-x[i]) } ); cnt=mom[i][j][1].ft, ac=-mom[i][j][1].sc; if(cnt>=0){ res=max(res, cnt); for(int k=i-1, ac2=ac; k>j; k--){ ac2+=x[k+1]-x[k]; if(ac2<=t[k]){ mom[k][j][1]=max(mom[k][j][1], {cnt+1, -ac2} ); } else{ mom[k][j][1]=max(mom[k][j][1], {cnt, -ac2} ); } } } } } cout<<res; return 0; }

Compilation message (stderr)

ho_t3.cpp: In function 'int32_t main()':
ho_t3.cpp:28:5: warning: variable 'hlt' set but not used [-Wunused-but-set-variable]
   28 | pii hlt={-1, -1};
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...