Submission #1092097

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10920972024-09-23 07:25:56vjudge1Uplifting Excursion (BOI22_vault)C++14
100 / 100
1279 ms4700 KiB
// BalticOI 2022 Day1 Uplifting Excursion
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
ios::sync_with_stdio(false), cin.tie(0);
LL M, L;
cin >> M >> L;
vector<LL> A(2 * M + 1), C(2 * M + 1);
for (LL i = 0; i <= 2 * M; i++) cin >> A[i];
LL sum = 0; // -M ... 0,
for (LL i = 0; i <= M; i++) sum += A[i] * (i - M), C[i] = A[i];
for (LL i = M + 1; i <= 2 * M; i++) { // L
C[i] = min((L - sum) / (i - M), A[i]), sum += C[i] * (i - M);
assert(sum <= L);
}
for (LL i = 0; i < M; i++) {
assert(sum <= L);
LL c = min((L - sum) / (M - i), A[i]);
sum += c * (M - i), C[i] -= c;
}
if (L - sum > M) return puts("impossible"), 0;
LL cs = 0, wc = 0;
const LL MIF = -4e18, B = M * M;
vector<LL> W{0}, V{0}; //
for (LL i = 0; i <= 2 * M; i++) {
cs += C[i]; //
if (i == M) continue;
LL k = 1, s = min(A[i] - C[i], B), w = i - M; //
while (k <= s) W.push_back(w * k), V.push_back(k), s -= k, k *= 2;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...