제출 #925042

#제출 시각아이디문제언어결과실행 시간메모리
925042NintsiChkhaidzeA Difficult(y) Choice (BOI21_books)C++17
10 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "books.h" typedef long long ll; #define pb push_back using namespace std; long long x[100005],b[100005]; void solve(int N, int K, long long A, int S) { ll s = 0; int k = K,n = N; for (int i = 1; i <= k; i++){ x[i] = skim(i); s += x[i]; } if (s >= 2*A) impossible(); int l = 1,r = n,id = 0; while (l <= r){ int mid = (l + r) >> 1; if (!x[mid]) x[mid] = skim(mid); if (x[mid] <= A) { id = mid; l = mid + 1; }else{ r = mid - 1; } } int idx = 0; for (int i = 1; i <= k; i++) b[++idx] = i; for (int i = id - k + 1; i <= id; i++){ if (i > k) b[++idx] = i; } s = 0; for (int i = 1; i <= idx; i++){ if (!x[b[i]]) x[b[i]] = skim(b[i]); if (i >= k) s -= x[b[i - k]]; s += x[b[i]]; if (i < k) continue; if (s >= A && s < 2*A){ vector <int> ans; for (int j = i - k + 1; j <= i; j++) ans.pb(b[j]); answer(ans); } } impossible(); }
#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...