Submission #590373

#TimeUsernameProblemLanguageResultExecution timeMemory
590373tutisUplifting Excursion (BOI22_vault)C++17
5 / 100
5056 ms8360 KiB
/*input 2 5 2 3 1 1 4 */ #include <bits/stdc++.h> using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); using ll = long long; using ull = unsigned long long; using ld = long double; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int M; ll L; cin >> M >> L; ll A[2 * M + 1]; for (int i = 0; i <= 2 * M; i++) cin >> A[i]; int D = 505000; vector<int> C(2 * D + 1, -1e18); C[D] = 0; int sum = 0; for (int i = 1; i <= M; i++) { for (int j = D + sum; j >= D - sum; j--) { for (int k = 1; k <= A[i + M]; k++) { if (j + k * i >= 0 && j + k * i <= 2 * D) C[j + k * i] = max(C[j + k * i], C[j] + k); } } sum += i * max(A[i + M], A[-i + M]); for (int j = D - sum; j <= D + sum; j++) { for (int k = 1; k <= A[-i + M]; k++) { if (j - k * i >= 0 && j - k * i <= 2 * D) C[j - k * i] = max(C[j - k * i], C[j] + k); } } } if (L + D >= 0 && L + D <= 2 * D && C[L + D] >= 0) cout << C[L + D] + A[M] << "\n"; else cout << "impossible\n"; }

Compilation message (stderr)

vault.cpp: In function 'int main()':
vault.cpp:23:27: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '-1.0e+18' to '-2147483648' [-Woverflow]
   23 |  vector<int> C(2 * D + 1, -1e18);
      |                           ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...