Submission #580441

# Submission time Handle Problem Language Result Execution time Memory
580441 2022-06-21T08:52:39 Z 조영욱(#8357) Uplifting Excursion (BOI22_vault) C++17
20 / 100
2941 ms 8140 KB
#include <bits/stdc++.h>
using namespace std;

int m;
long long l;
int dp0[1000001];
int dp[1000001];
const int zero=500000;
int arr[202];
typedef pair<int,int> P;

int main(void) {
    scanf("%d %lld",&m,&l);
    if (l>zero||l<-zero) {
        printf("impossible");
        return 0;
    }
    for(int i=1;i<=m*2+1;i++) {
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<=zero*2;i++) {
        dp0[i]=-1e7;
        dp[i]=-1e7;
    }
    dp[zero]=0;
    for(int i=1;i<=m*2+1;i++) {
        if (i==m+1){
            for(int j=0;j<=zero*2;j++) {
                dp[j]=dp[j]+arr[m+1];
            }
            continue;
        }
        int val=abs(i-m-1);
        if (i<m+1) {
            for(int j=zero*2;j>zero*2-val;j--) {
                deque<P> dq;
                for(int k=j;k>=0;k-=val) {
                    int now=dp[k]+k/val;
                    while (!dq.empty()&&dq.back().second>k+arr[i]*val) {
                        dq.pop_back();
                    }
                    while (!dq.empty()&&dq.front().first<=now) {
                        dq.pop_front();
                    }
                    dq.push_front(P(now,k));
                    dp0[k]=max(dp0[k],dq.back().first-k/val);
                }
            }
        }
        else {
            for(int j=0;j<val;j++) {
                deque<P> dq;
                for(int k=j;k<=zero*2;k+=val) {
                    int now=dp[k]-k/val;
                    while (!dq.empty()&&dq.back().second<k-arr[i]*val) {
                        dq.pop_back();
                    }
                    while (!dq.empty()&&dq.front().first<=now) {
                        dq.pop_front();
                    }
                    dq.push_front(P(now,k));
                    dp0[k]=max(dp0[k],dq.back().first+k/val);
                }
            }
        }
        for(int j=0;j<=zero*2;j++) {
            dp[j]=dp0[j];
            dp0[j]=-1e7;
        }
    }
    if (dp[zero+l]<0) {
        printf("impossible");
        return 0;
    }
    printf("%d",dp[zero+l]);
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %lld",&m,&l);
      |     ~~~~~^~~~~~~~~~~~~~~~~
vault.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d",&arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 54 ms 8020 KB Output is correct
2 Correct 87 ms 8104 KB Output is correct
3 Correct 34 ms 8112 KB Output is correct
4 Correct 294 ms 8104 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1462 ms 8108 KB Output is correct
7 Correct 1624 ms 8112 KB Output is correct
8 Correct 1463 ms 8108 KB Output is correct
9 Correct 1539 ms 8108 KB Output is correct
10 Correct 1639 ms 8108 KB Output is correct
11 Correct 1589 ms 8108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 8020 KB Output is correct
2 Correct 87 ms 8104 KB Output is correct
3 Correct 34 ms 8112 KB Output is correct
4 Correct 294 ms 8104 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1462 ms 8108 KB Output is correct
7 Correct 1624 ms 8112 KB Output is correct
8 Correct 1463 ms 8108 KB Output is correct
9 Correct 1539 ms 8108 KB Output is correct
10 Correct 1639 ms 8108 KB Output is correct
11 Correct 1589 ms 8108 KB Output is correct
12 Correct 55 ms 8108 KB Output is correct
13 Correct 83 ms 8108 KB Output is correct
14 Correct 32 ms 8124 KB Output is correct
15 Correct 303 ms 8108 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1331 ms 8112 KB Output is correct
18 Correct 1416 ms 8104 KB Output is correct
19 Correct 1375 ms 8116 KB Output is correct
20 Correct 1371 ms 8108 KB Output is correct
21 Correct 1518 ms 8108 KB Output is correct
22 Correct 1502 ms 8108 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 2860 ms 8104 KB Output is correct
25 Correct 2769 ms 8120 KB Output is correct
26 Correct 2878 ms 8108 KB Output is correct
27 Correct 2849 ms 8140 KB Output is correct
28 Correct 2907 ms 8108 KB Output is correct
29 Correct 2941 ms 8104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 268 ms 8104 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 268 ms 8104 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 268 ms 8104 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 54 ms 8020 KB Output is correct
2 Correct 87 ms 8104 KB Output is correct
3 Correct 34 ms 8112 KB Output is correct
4 Correct 294 ms 8104 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1462 ms 8108 KB Output is correct
7 Correct 1624 ms 8112 KB Output is correct
8 Correct 1463 ms 8108 KB Output is correct
9 Correct 1539 ms 8108 KB Output is correct
10 Correct 1639 ms 8108 KB Output is correct
11 Correct 1589 ms 8108 KB Output is correct
12 Correct 268 ms 8104 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 268 ms 8104 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 54 ms 8020 KB Output is correct
2 Correct 87 ms 8104 KB Output is correct
3 Correct 34 ms 8112 KB Output is correct
4 Correct 294 ms 8104 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1462 ms 8108 KB Output is correct
7 Correct 1624 ms 8112 KB Output is correct
8 Correct 1463 ms 8108 KB Output is correct
9 Correct 1539 ms 8108 KB Output is correct
10 Correct 1639 ms 8108 KB Output is correct
11 Correct 1589 ms 8108 KB Output is correct
12 Correct 55 ms 8108 KB Output is correct
13 Correct 83 ms 8108 KB Output is correct
14 Correct 32 ms 8124 KB Output is correct
15 Correct 303 ms 8108 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1331 ms 8112 KB Output is correct
18 Correct 1416 ms 8104 KB Output is correct
19 Correct 1375 ms 8116 KB Output is correct
20 Correct 1371 ms 8108 KB Output is correct
21 Correct 1518 ms 8108 KB Output is correct
22 Correct 1502 ms 8108 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 2860 ms 8104 KB Output is correct
25 Correct 2769 ms 8120 KB Output is correct
26 Correct 2878 ms 8108 KB Output is correct
27 Correct 2849 ms 8140 KB Output is correct
28 Correct 2907 ms 8108 KB Output is correct
29 Correct 2941 ms 8104 KB Output is correct
30 Correct 268 ms 8104 KB Output is correct
31 Incorrect 0 ms 212 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 268 ms 8104 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 54 ms 8020 KB Output is correct
2 Correct 87 ms 8104 KB Output is correct
3 Correct 34 ms 8112 KB Output is correct
4 Correct 294 ms 8104 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1462 ms 8108 KB Output is correct
7 Correct 1624 ms 8112 KB Output is correct
8 Correct 1463 ms 8108 KB Output is correct
9 Correct 1539 ms 8108 KB Output is correct
10 Correct 1639 ms 8108 KB Output is correct
11 Correct 1589 ms 8108 KB Output is correct
12 Correct 55 ms 8108 KB Output is correct
13 Correct 83 ms 8108 KB Output is correct
14 Correct 32 ms 8124 KB Output is correct
15 Correct 303 ms 8108 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1331 ms 8112 KB Output is correct
18 Correct 1416 ms 8104 KB Output is correct
19 Correct 1375 ms 8116 KB Output is correct
20 Correct 1371 ms 8108 KB Output is correct
21 Correct 1518 ms 8108 KB Output is correct
22 Correct 1502 ms 8108 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 2860 ms 8104 KB Output is correct
25 Correct 2769 ms 8120 KB Output is correct
26 Correct 2878 ms 8108 KB Output is correct
27 Correct 2849 ms 8140 KB Output is correct
28 Correct 2907 ms 8108 KB Output is correct
29 Correct 2941 ms 8104 KB Output is correct
30 Correct 268 ms 8104 KB Output is correct
31 Incorrect 0 ms 212 KB Output isn't correct
32 Halted 0 ms 0 KB -