Submission #489375

# Submission time Handle Problem Language Result Execution time Memory
489375 2021-11-22T18:56:12 Z bigDuck Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
1 ms 336 KB
#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]={0, 0};

//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].ft+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], {cnt, -(ac+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

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 time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Incorrect 1 ms 324 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Incorrect 1 ms 324 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Incorrect 1 ms 324 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Incorrect 1 ms 324 KB Output isn't correct
8 Halted 0 ms 0 KB -