답안 #576714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576714 2022-06-13T10:31:40 Z Lucpp Uplifting Excursion (BOI22_vault) C++14
20 / 100
1253 ms 4280 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX = 50*100*101;
const int INF = 1e8;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int M; ll L;
    cin >> M >> L;
    vector<int> a(2*M+1);
    for(int i = 0; i < 2*M+1; ++i) cin >> a[i];
    if(L > MAX || L < -MAX){
        cout << "impossible\n";
        return 0;
    }
    vector<int> dp(2*MAX+1, -INF);
    dp[MAX] = 0;
    for(int i = 0; i < 2*M+1; ++i){
        if(i == M){
            for(int j = 0; j < 2*MAX+1; ++j) dp[j] += a[M];
            continue;
        }
        int v = i-M;
        int start = 0;
        if(v < 0) start = 2*MAX+1+v;
        for(int j = start; j < start + abs(v); ++j){
            deque<pair<int, int>> q;
            for(int k = 0; j+v*k >= 0 && j+v*k < 2*MAX+1; ++k){
                int x = dp[j+v*k]-k;
                while(!q.empty() && x > q.back().first) q.pop_back();
                q.emplace_back(x, k);
                if(k - q.front().second > a[i]) q.pop_front();
                dp[j+v*k] = q.front().first + k;
            }
        }
    }
    if(dp[MAX+L] < 0) cout << "impossible\n";
    else cout << dp[MAX+L] << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4180 KB Output is correct
2 Correct 37 ms 4180 KB Output is correct
3 Correct 14 ms 4180 KB Output is correct
4 Correct 121 ms 4180 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 599 ms 4180 KB Output is correct
7 Correct 593 ms 4180 KB Output is correct
8 Correct 627 ms 4180 KB Output is correct
9 Correct 613 ms 4180 KB Output is correct
10 Correct 596 ms 4180 KB Output is correct
11 Correct 586 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4180 KB Output is correct
2 Correct 37 ms 4180 KB Output is correct
3 Correct 14 ms 4180 KB Output is correct
4 Correct 121 ms 4180 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 599 ms 4180 KB Output is correct
7 Correct 593 ms 4180 KB Output is correct
8 Correct 627 ms 4180 KB Output is correct
9 Correct 613 ms 4180 KB Output is correct
10 Correct 596 ms 4180 KB Output is correct
11 Correct 586 ms 4180 KB Output is correct
12 Correct 25 ms 4180 KB Output is correct
13 Correct 36 ms 4180 KB Output is correct
14 Correct 15 ms 4180 KB Output is correct
15 Correct 119 ms 4180 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 607 ms 4180 KB Output is correct
18 Correct 605 ms 4180 KB Output is correct
19 Correct 610 ms 4180 KB Output is correct
20 Correct 617 ms 4180 KB Output is correct
21 Correct 582 ms 4180 KB Output is correct
22 Correct 584 ms 4180 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1253 ms 4180 KB Output is correct
25 Correct 1207 ms 4180 KB Output is correct
26 Correct 1237 ms 4180 KB Output is correct
27 Correct 1228 ms 4180 KB Output is correct
28 Correct 1206 ms 4180 KB Output is correct
29 Correct 1194 ms 4260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 4280 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 4280 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 4280 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4180 KB Output is correct
2 Correct 37 ms 4180 KB Output is correct
3 Correct 14 ms 4180 KB Output is correct
4 Correct 121 ms 4180 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 599 ms 4180 KB Output is correct
7 Correct 593 ms 4180 KB Output is correct
8 Correct 627 ms 4180 KB Output is correct
9 Correct 613 ms 4180 KB Output is correct
10 Correct 596 ms 4180 KB Output is correct
11 Correct 586 ms 4180 KB Output is correct
12 Correct 117 ms 4280 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 4280 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4180 KB Output is correct
2 Correct 37 ms 4180 KB Output is correct
3 Correct 14 ms 4180 KB Output is correct
4 Correct 121 ms 4180 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 599 ms 4180 KB Output is correct
7 Correct 593 ms 4180 KB Output is correct
8 Correct 627 ms 4180 KB Output is correct
9 Correct 613 ms 4180 KB Output is correct
10 Correct 596 ms 4180 KB Output is correct
11 Correct 586 ms 4180 KB Output is correct
12 Correct 25 ms 4180 KB Output is correct
13 Correct 36 ms 4180 KB Output is correct
14 Correct 15 ms 4180 KB Output is correct
15 Correct 119 ms 4180 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 607 ms 4180 KB Output is correct
18 Correct 605 ms 4180 KB Output is correct
19 Correct 610 ms 4180 KB Output is correct
20 Correct 617 ms 4180 KB Output is correct
21 Correct 582 ms 4180 KB Output is correct
22 Correct 584 ms 4180 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1253 ms 4180 KB Output is correct
25 Correct 1207 ms 4180 KB Output is correct
26 Correct 1237 ms 4180 KB Output is correct
27 Correct 1228 ms 4180 KB Output is correct
28 Correct 1206 ms 4180 KB Output is correct
29 Correct 1194 ms 4260 KB Output is correct
30 Correct 117 ms 4280 KB Output is correct
31 Incorrect 0 ms 212 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 4280 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 4180 KB Output is correct
2 Correct 37 ms 4180 KB Output is correct
3 Correct 14 ms 4180 KB Output is correct
4 Correct 121 ms 4180 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 599 ms 4180 KB Output is correct
7 Correct 593 ms 4180 KB Output is correct
8 Correct 627 ms 4180 KB Output is correct
9 Correct 613 ms 4180 KB Output is correct
10 Correct 596 ms 4180 KB Output is correct
11 Correct 586 ms 4180 KB Output is correct
12 Correct 25 ms 4180 KB Output is correct
13 Correct 36 ms 4180 KB Output is correct
14 Correct 15 ms 4180 KB Output is correct
15 Correct 119 ms 4180 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 607 ms 4180 KB Output is correct
18 Correct 605 ms 4180 KB Output is correct
19 Correct 610 ms 4180 KB Output is correct
20 Correct 617 ms 4180 KB Output is correct
21 Correct 582 ms 4180 KB Output is correct
22 Correct 584 ms 4180 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1253 ms 4180 KB Output is correct
25 Correct 1207 ms 4180 KB Output is correct
26 Correct 1237 ms 4180 KB Output is correct
27 Correct 1228 ms 4180 KB Output is correct
28 Correct 1206 ms 4180 KB Output is correct
29 Correct 1194 ms 4260 KB Output is correct
30 Correct 117 ms 4280 KB Output is correct
31 Incorrect 0 ms 212 KB Output isn't correct
32 Halted 0 ms 0 KB -