Submission #1224306

#TimeUsernameProblemLanguageResultExecution timeMemory
1224306SpyrosAlivA Difficult(y) Choice (BOI21_books)C++20
0 / 100
1 ms1200 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; #define ll long long int n, k, s; ll a; void solve(int N, int K, ll A, int S) { n = N; k = K; a = A; s = S; vector<ll> arr(n+1); for (int i = 1; i <= n; i++) { arr[i] = skim(i); } ll currS = 0; int lastPlace = k; vector<int> index(k+2); for (int i = 1; i <= k; i++) { currS += arr[i]; index[i] = i; } index[k+1] = n+1; while (currS < a) { int lst = lastPlace; if (lst == 0) { impossible(); } int allow = index[lst] - 1; currS -= arr[lst]; for (int j = lastPlace+1; j <= allow; j++) { currS += arr[j]; index[lastPlace] = j; if (currS >= a && currS <= 2*a) { vector<int> fin; for (int i = 1; i <= k; i++) { fin.push_back(index[i]); } answer(fin); return; } else if (currS < a) { continue; } else if (currS > 2*a) { currS -= arr[j]; index[lastPlace] = j-1; currS += arr[j-1]; break; } } lastPlace--; } if (currS > 2 * a || currS < a) { impossible(); return; } else { vector<int> fin; for (int i = 1; i <= k; i++) { fin.push_back(index[i]); } answer(fin); return; } }
#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...