Submission #595494

# Submission time Handle Problem Language Result Execution time Memory
595494 2022-07-13T19:09:15 Z Deepesson Uplifting Excursion (BOI22_vault) C++17
5 / 100
5000 ms 5248 KB
#include <bits/stdc++.h>
#define MAX 1000005
int maximo[MAX];
int bonus = MAX/2;
typedef std::pair<int,int> pii;
int main()
{
    long long N,M;
    std::cin>>N>>M;
    if(abs(M)>bonus){
        std::cout<<"impossible\n";
        return 0;
    }
    for(auto&x:maximo)x=-(1e6);
    maximo[bonus]=0;
    for(int i=-N;i<=N;++i){
        int c;
        std::cin>>c;
        if(!c)continue;
        int valor=abs(i);
        if(!valor){
            for(auto&x:maximo)x+=c;
            continue;
        }
        std::priority_queue<pii> vals[valor];
        ///Da direita para a esquerda
        if(i>0){
            for(int j=0;j!=MAX-1;++j){
                if(j-i<0)continue;
                int mod = j%valor;
                int kok = j/valor;
                int v = -1;
                while(vals[mod].size()){
                    if(kok-vals[mod].top().second>c){
                        vals[mod].pop();
                        continue;
                    }
                    v=vals[mod].top().first+kok;
                    break;
                }
                vals[mod].push({maximo[j]-kok,kok});
                maximo[j]=std::max(maximo[j],v);
            }
        }else if(i<0){
            for(int j=MAX-1;j!=-1;--j){
                if(j-i<0)continue;
                int mod = j%valor;
                int kok = j/valor;
                int v = -1;
                while(vals[mod].size()){
                    if(abs(kok-vals[mod].top().second)>c){
                        vals[mod].pop();
                        continue;
                    }
                    v=vals[mod].top().first-kok;
                    break;
                }
                vals[mod].push({maximo[j]+kok,kok});
                maximo[j]=std::max(maximo[j],v);
            }
        }
    }
    ///como proceder caso x=0?
    if(maximo[M+bonus]<=0){
        std::cout<<"impossible\n";
        return 0;
    }
    std::cout<<maximo[M+bonus]<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 102 ms 4196 KB Output is correct
2 Correct 73 ms 4192 KB Output is correct
3 Correct 32 ms 4180 KB Output is correct
4 Correct 242 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3377 ms 4760 KB Output is correct
7 Correct 1487 ms 4480 KB Output is correct
8 Correct 3348 ms 4744 KB Output is correct
9 Correct 3875 ms 5248 KB Output is correct
10 Correct 73 ms 4240 KB Output is correct
11 Correct 138 ms 4260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 4196 KB Output is correct
2 Correct 73 ms 4192 KB Output is correct
3 Correct 32 ms 4180 KB Output is correct
4 Correct 242 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3377 ms 4760 KB Output is correct
7 Correct 1487 ms 4480 KB Output is correct
8 Correct 3348 ms 4744 KB Output is correct
9 Correct 3875 ms 5248 KB Output is correct
10 Correct 73 ms 4240 KB Output is correct
11 Correct 138 ms 4260 KB Output is correct
12 Correct 103 ms 4200 KB Output is correct
13 Correct 74 ms 4192 KB Output is correct
14 Correct 32 ms 4212 KB Output is correct
15 Correct 248 ms 4188 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3373 ms 4812 KB Output is correct
18 Correct 1488 ms 4660 KB Output is correct
19 Correct 3312 ms 4916 KB Output is correct
20 Correct 3831 ms 5040 KB Output is correct
21 Correct 72 ms 4180 KB Output is correct
22 Correct 138 ms 4144 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Execution timed out 5038 ms 4872 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 248 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 248 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 248 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 102 ms 4196 KB Output is correct
2 Correct 73 ms 4192 KB Output is correct
3 Correct 32 ms 4180 KB Output is correct
4 Correct 242 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3377 ms 4760 KB Output is correct
7 Correct 1487 ms 4480 KB Output is correct
8 Correct 3348 ms 4744 KB Output is correct
9 Correct 3875 ms 5248 KB Output is correct
10 Correct 73 ms 4240 KB Output is correct
11 Correct 138 ms 4260 KB Output is correct
12 Correct 248 ms 4200 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 248 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 102 ms 4196 KB Output is correct
2 Correct 73 ms 4192 KB Output is correct
3 Correct 32 ms 4180 KB Output is correct
4 Correct 242 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3377 ms 4760 KB Output is correct
7 Correct 1487 ms 4480 KB Output is correct
8 Correct 3348 ms 4744 KB Output is correct
9 Correct 3875 ms 5248 KB Output is correct
10 Correct 73 ms 4240 KB Output is correct
11 Correct 138 ms 4260 KB Output is correct
12 Correct 103 ms 4200 KB Output is correct
13 Correct 74 ms 4192 KB Output is correct
14 Correct 32 ms 4212 KB Output is correct
15 Correct 248 ms 4188 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3373 ms 4812 KB Output is correct
18 Correct 1488 ms 4660 KB Output is correct
19 Correct 3312 ms 4916 KB Output is correct
20 Correct 3831 ms 5040 KB Output is correct
21 Correct 72 ms 4180 KB Output is correct
22 Correct 138 ms 4144 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Execution timed out 5038 ms 4872 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 248 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 102 ms 4196 KB Output is correct
2 Correct 73 ms 4192 KB Output is correct
3 Correct 32 ms 4180 KB Output is correct
4 Correct 242 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3377 ms 4760 KB Output is correct
7 Correct 1487 ms 4480 KB Output is correct
8 Correct 3348 ms 4744 KB Output is correct
9 Correct 3875 ms 5248 KB Output is correct
10 Correct 73 ms 4240 KB Output is correct
11 Correct 138 ms 4260 KB Output is correct
12 Correct 103 ms 4200 KB Output is correct
13 Correct 74 ms 4192 KB Output is correct
14 Correct 32 ms 4212 KB Output is correct
15 Correct 248 ms 4188 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3373 ms 4812 KB Output is correct
18 Correct 1488 ms 4660 KB Output is correct
19 Correct 3312 ms 4916 KB Output is correct
20 Correct 3831 ms 5040 KB Output is correct
21 Correct 72 ms 4180 KB Output is correct
22 Correct 138 ms 4144 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Execution timed out 5038 ms 4872 KB Time limit exceeded
25 Halted 0 ms 0 KB -