답안 #595498

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595498 2022-07-13T19:14:19 Z Deepesson Uplifting Excursion (BOI22_vault) C++17
0 / 100
5000 ms 4248 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::deque<int> vals[valor];
        ///Da direita para a esquerda
        if(i>0){
            for(int j=0;j!=MAX-1;++j){
                int mod = j%valor;
                int kok = j/valor;
                int v = -(1e6);
                for(auto&x:vals[mod]){
                    v=std::max(v,x+kok);
                }
                vals[mod].push_back(maximo[j]-kok);
                if(vals[mod].size()>c)vals[mod].pop_front();
                maximo[j]=std::max(maximo[j],v);
            }
        }else if(i<0){
            for(int j=MAX-1;j!=-1;--j){
                int mod = j%valor;
                int kok = j/valor;
                int v = -(1e6);
                for(auto&x:vals[mod]){
                    v=std::max(v,x-kok);
                }
                vals[mod].push_back(maximo[j]+kok);
                if(vals[mod].size()>c)vals[mod].pop_front();
                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";
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:36:36: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |                 if(vals[mod].size()>c)vals[mod].pop_front();
      |                    ~~~~~~~~~~~~~~~~^~
vault.cpp:48:36: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |                 if(vals[mod].size()>c)vals[mod].pop_front();
      |                    ~~~~~~~~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 4196 KB Output is correct
2 Correct 61 ms 4200 KB Output is correct
3 Correct 22 ms 4212 KB Output is correct
4 Correct 190 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4295 ms 4248 KB Output is correct
7 Correct 1711 ms 4244 KB Output is correct
8 Correct 4019 ms 4244 KB Output is correct
9 Execution timed out 5098 ms 4180 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 4196 KB Output is correct
2 Correct 61 ms 4200 KB Output is correct
3 Correct 22 ms 4212 KB Output is correct
4 Correct 190 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4295 ms 4248 KB Output is correct
7 Correct 1711 ms 4244 KB Output is correct
8 Correct 4019 ms 4244 KB Output is correct
9 Execution timed out 5098 ms 4180 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 4196 KB Output is correct
2 Correct 61 ms 4200 KB Output is correct
3 Correct 22 ms 4212 KB Output is correct
4 Correct 190 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4295 ms 4248 KB Output is correct
7 Correct 1711 ms 4244 KB Output is correct
8 Correct 4019 ms 4244 KB Output is correct
9 Execution timed out 5098 ms 4180 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 4196 KB Output is correct
2 Correct 61 ms 4200 KB Output is correct
3 Correct 22 ms 4212 KB Output is correct
4 Correct 190 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4295 ms 4248 KB Output is correct
7 Correct 1711 ms 4244 KB Output is correct
8 Correct 4019 ms 4244 KB Output is correct
9 Execution timed out 5098 ms 4180 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 4200 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 4196 KB Output is correct
2 Correct 61 ms 4200 KB Output is correct
3 Correct 22 ms 4212 KB Output is correct
4 Correct 190 ms 4208 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4295 ms 4248 KB Output is correct
7 Correct 1711 ms 4244 KB Output is correct
8 Correct 4019 ms 4244 KB Output is correct
9 Execution timed out 5098 ms 4180 KB Time limit exceeded
10 Halted 0 ms 0 KB -