Submission #602632

# Submission time Handle Problem Language Result Execution time Memory
602632 2022-07-23T09:40:16 Z veehz Uplifting Excursion (BOI22_vault) C++17
5 / 100
5000 ms 4180 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll negativeOne = -1;
ll m, l;
int maxi, mini;
vector<ll> a, x;

inline auto& get(int i) { return a[i + m]; }
inline auto& getx(int i) {
  if (i < mini || i > maxi) return negativeOne;
  return x[i - mini];
}

int main() {
  cin >> m >> l;
  ll ans = 0;
  a.resize(2 * m + 1);
  for (int i = 0; i < 2 * m + 1; i++) cin >> a[i];

  maxi = mini = 0;
  for (int i = 1; i <= m; i++) {
    maxi += get(i) * i;
    mini -= get(-i) * i;
  }


  x.assign(maxi - mini + 1, negativeOne);
  getx(0) = get(0);
  for (int i = 1; i <= m; i++) {
    for (int j = maxi; j >= mini; j--) {
      for (int k = 1; k <= get(i); k++) {
        if (getx(j - k * i) != negativeOne) {
          getx(j) = max(getx(j), getx(j - k * i) + k);
        }
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = mini; j <= maxi; j++) {
      for (int k = 1; k <= get(-i); k++) {
        if (getx(j + k*i) != negativeOne) {
          getx(j) = max(getx(j), getx(j + k*i) + k);
        }
      }
    }
  }

  if(getx(l) != negativeOne) cout << getx(l) << endl;
  else cout << "impossible" << endl;
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:19:6: warning: unused variable 'ans' [-Wunused-variable]
   19 |   ll ans = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 331 ms 800 KB Output is correct
6 Correct 377 ms 820 KB Output is correct
7 Correct 63 ms 588 KB Output is correct
8 Correct 326 ms 784 KB Output is correct
9 Correct 1189 ms 1236 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 331 ms 800 KB Output is correct
6 Correct 377 ms 820 KB Output is correct
7 Correct 63 ms 588 KB Output is correct
8 Correct 326 ms 784 KB Output is correct
9 Correct 1189 ms 1236 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 356 ms 804 KB Output is correct
17 Correct 361 ms 816 KB Output is correct
18 Correct 73 ms 468 KB Output is correct
19 Correct 339 ms 788 KB Output is correct
20 Correct 1187 ms 1236 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Execution timed out 5064 ms 4180 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 331 ms 800 KB Output is correct
6 Correct 377 ms 820 KB Output is correct
7 Correct 63 ms 588 KB Output is correct
8 Correct 326 ms 784 KB Output is correct
9 Correct 1189 ms 1236 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Runtime error 2 ms 468 KB Execution killed with signal 6
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 331 ms 800 KB Output is correct
6 Correct 377 ms 820 KB Output is correct
7 Correct 63 ms 588 KB Output is correct
8 Correct 326 ms 784 KB Output is correct
9 Correct 1189 ms 1236 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 356 ms 804 KB Output is correct
17 Correct 361 ms 816 KB Output is correct
18 Correct 73 ms 468 KB Output is correct
19 Correct 339 ms 788 KB Output is correct
20 Correct 1187 ms 1236 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Execution timed out 5064 ms 4180 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 331 ms 800 KB Output is correct
6 Correct 377 ms 820 KB Output is correct
7 Correct 63 ms 588 KB Output is correct
8 Correct 326 ms 784 KB Output is correct
9 Correct 1189 ms 1236 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 356 ms 804 KB Output is correct
17 Correct 361 ms 816 KB Output is correct
18 Correct 73 ms 468 KB Output is correct
19 Correct 339 ms 788 KB Output is correct
20 Correct 1187 ms 1236 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Execution timed out 5064 ms 4180 KB Time limit exceeded
24 Halted 0 ms 0 KB -