Submission #590381

#TimeUsernameProblemLanguageResultExecution timeMemory
590381tutisUplifting Excursion (BOI22_vault)C++17
0 / 100
5014 ms4180 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, -1e9); C[D] = 0; int sum = 0; for (int i = 1; i <= M; i++) { for (int k = 1; k <= A[i + M]; k++) { for (int j = D + sum; j >= D - sum; j--) { C[j + i] = max(C[j + i], C[j] + 1); } sum += i; } for (int k = 1; k <= A[-i + M]; k++) { for (int j = D - sum; j <= D + sum; j++) { C[j - i] = max(C[j - i], C[j] + 1); } } } if (L + D >= 0 && L + D <= 2 * D && C[L + D] >= 0) cout << C[L + D] + A[M] << "\n"; else cout << "impossible\n"; }
#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...