답안 #580329

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580329 2022-06-21T05:36:01 Z 반딧불(#8355) Uplifting Excursion (BOI22_vault) C++17
0 / 100
134 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
int arr[702];
int DP[2][20002];

int main(){
    scanf("%d %d", &n, &k);
    for(int i=0; i<=n+n; i++) scanf("%d", &arr[i]);
    if(k < -10000 || k > 10000){
        puts("impossible");
        return 0;
    }
    for(int i=0; i<=20000; i++) DP[0][i] = DP[1][i] = -1e9;
    DP[1][10000] = 0;
    vector<ll> vec;
    for(int i=0; i<=n+n; i++) for(int j=0; j<arr[i]; j++) vec.push_back(i-n);
    for(int i=0; i<(int)vec.size(); i++){
        int b = i%2;
        for(int j=0; j<=20000; j++){
            if(DP[!b][j]<0) continue;
            DP[b][j] = max(DP[b][j], DP[!b][j]);
            if(0 <= j+vec[i] && j+vec[i] <= 20000) DP[b][j+vec[i]] = max(DP[b][j+vec[i]], DP[!b][j]+1);
        }
    }
    int ans = DP[((int)vec.size()+1)%2][10000+k];
    if(ans<0) printf("impossible");
    else printf("%d", ans);
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
vault.cpp:13:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(int i=0; i<=n+n; i++) scanf("%d", &arr[i]);
      |                               ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 134 ms 468 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 134 ms 468 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 134 ms 468 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 134 ms 468 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 134 ms 468 KB Output isn't correct
7 Halted 0 ms 0 KB -