답안 #653555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
653555 2022-10-27T09:00:24 Z atigun Uplifting Excursion (BOI22_vault) C++14
5 / 100
5000 ms 16204 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 100;

int M;
ll L;

vector<int> pos(maxn+5), neg(maxn+5);

void solve(){
  cin >> M >> L;
  for(int i = 1; i <= M; i++)
    cin >> neg[M-i+1];
  ll ans;
  cin >> ans;
  for(int i = 1; i <= M; i++)
    cin >> pos[i];
  int maxn3 = (maxn*maxn+1)/2*maxn;
  vector<ll> knapsack1(maxn3+5, -1e18), knapsack2(maxn3+5, -1e18);
  knapsack1[0] = knapsack2[0] = 0;
  for(int i = 1; i <= M; i++){
    for(int make = maxn3; make >= 0; make--){
      for(int use = 1; use <= max(pos[i], neg[i]); use++){
        if(use <= pos[i] && use*i <= make && knapsack1[make-use*i] != -1e18)
          knapsack1[make] = max(knapsack1[make], knapsack1[make-use*i]+use);
        if(use <= neg[i] && use*i <= make && knapsack2[make-use*i] != -1e18)
          knapsack2[make] = max(knapsack2[make], knapsack2[make-use*i]+use);
      }
    }
  }
  ll add = -1e18;
  for(int i = 0; i <= maxn3; i++){
    ll need = L-i;
    if(need > 0){
      continue;
    }else if(need == 0){
      add = max(add, knapsack1[i]);
    }else if(-need >= maxn3 || knapsack2[-need] == -1e18 || knapsack1[i] == -1e18){
      continue;
    }else{
      add = max(add, knapsack1[i] + knapsack2[-need]);
    }
  }
  if(add == -1e18){
    cout << "impossible\n";
  }else{
    cout << ans+add;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  // cin >> tt;
  while(tt--){
    solve();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 8148 KB Output is correct
2 Correct 24 ms 8068 KB Output is correct
3 Correct 11 ms 8148 KB Output is correct
4 Correct 68 ms 8148 KB Output is correct
5 Correct 2219 ms 8140 KB Output is correct
6 Correct 2330 ms 8148 KB Output is correct
7 Correct 1131 ms 8148 KB Output is correct
8 Correct 2281 ms 8148 KB Output is correct
9 Correct 3586 ms 8148 KB Output is correct
10 Correct 193 ms 8148 KB Output is correct
11 Correct 118 ms 8148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 8148 KB Output is correct
2 Correct 24 ms 8068 KB Output is correct
3 Correct 11 ms 8148 KB Output is correct
4 Correct 68 ms 8148 KB Output is correct
5 Correct 2219 ms 8140 KB Output is correct
6 Correct 2330 ms 8148 KB Output is correct
7 Correct 1131 ms 8148 KB Output is correct
8 Correct 2281 ms 8148 KB Output is correct
9 Correct 3586 ms 8148 KB Output is correct
10 Correct 193 ms 8148 KB Output is correct
11 Correct 118 ms 8148 KB Output is correct
12 Correct 14 ms 8148 KB Output is correct
13 Correct 14 ms 8160 KB Output is correct
14 Correct 15 ms 8160 KB Output is correct
15 Correct 69 ms 8148 KB Output is correct
16 Correct 1987 ms 8148 KB Output is correct
17 Correct 2157 ms 8148 KB Output is correct
18 Correct 977 ms 8144 KB Output is correct
19 Correct 2064 ms 8148 KB Output is correct
20 Correct 3245 ms 8148 KB Output is correct
21 Correct 128 ms 8148 KB Output is correct
22 Correct 117 ms 8148 KB Output is correct
23 Execution timed out 5084 ms 8148 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 8148 KB Output is correct
2 Runtime error 791 ms 16204 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 8148 KB Output is correct
2 Runtime error 791 ms 16204 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 8148 KB Output is correct
2 Runtime error 791 ms 16204 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 8148 KB Output is correct
2 Correct 24 ms 8068 KB Output is correct
3 Correct 11 ms 8148 KB Output is correct
4 Correct 68 ms 8148 KB Output is correct
5 Correct 2219 ms 8140 KB Output is correct
6 Correct 2330 ms 8148 KB Output is correct
7 Correct 1131 ms 8148 KB Output is correct
8 Correct 2281 ms 8148 KB Output is correct
9 Correct 3586 ms 8148 KB Output is correct
10 Correct 193 ms 8148 KB Output is correct
11 Correct 118 ms 8148 KB Output is correct
12 Correct 62 ms 8148 KB Output is correct
13 Runtime error 791 ms 16204 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 8148 KB Output is correct
2 Runtime error 791 ms 16204 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 8148 KB Output is correct
2 Correct 24 ms 8068 KB Output is correct
3 Correct 11 ms 8148 KB Output is correct
4 Correct 68 ms 8148 KB Output is correct
5 Correct 2219 ms 8140 KB Output is correct
6 Correct 2330 ms 8148 KB Output is correct
7 Correct 1131 ms 8148 KB Output is correct
8 Correct 2281 ms 8148 KB Output is correct
9 Correct 3586 ms 8148 KB Output is correct
10 Correct 193 ms 8148 KB Output is correct
11 Correct 118 ms 8148 KB Output is correct
12 Correct 14 ms 8148 KB Output is correct
13 Correct 14 ms 8160 KB Output is correct
14 Correct 15 ms 8160 KB Output is correct
15 Correct 69 ms 8148 KB Output is correct
16 Correct 1987 ms 8148 KB Output is correct
17 Correct 2157 ms 8148 KB Output is correct
18 Correct 977 ms 8144 KB Output is correct
19 Correct 2064 ms 8148 KB Output is correct
20 Correct 3245 ms 8148 KB Output is correct
21 Correct 128 ms 8148 KB Output is correct
22 Correct 117 ms 8148 KB Output is correct
23 Execution timed out 5084 ms 8148 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 8148 KB Output is correct
2 Runtime error 791 ms 16204 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 8148 KB Output is correct
2 Correct 24 ms 8068 KB Output is correct
3 Correct 11 ms 8148 KB Output is correct
4 Correct 68 ms 8148 KB Output is correct
5 Correct 2219 ms 8140 KB Output is correct
6 Correct 2330 ms 8148 KB Output is correct
7 Correct 1131 ms 8148 KB Output is correct
8 Correct 2281 ms 8148 KB Output is correct
9 Correct 3586 ms 8148 KB Output is correct
10 Correct 193 ms 8148 KB Output is correct
11 Correct 118 ms 8148 KB Output is correct
12 Correct 14 ms 8148 KB Output is correct
13 Correct 14 ms 8160 KB Output is correct
14 Correct 15 ms 8160 KB Output is correct
15 Correct 69 ms 8148 KB Output is correct
16 Correct 1987 ms 8148 KB Output is correct
17 Correct 2157 ms 8148 KB Output is correct
18 Correct 977 ms 8144 KB Output is correct
19 Correct 2064 ms 8148 KB Output is correct
20 Correct 3245 ms 8148 KB Output is correct
21 Correct 128 ms 8148 KB Output is correct
22 Correct 117 ms 8148 KB Output is correct
23 Execution timed out 5084 ms 8148 KB Time limit exceeded
24 Halted 0 ms 0 KB -