Submission #773459

#TimeUsernameProblemLanguageResultExecution timeMemory
773459ImeonA Difficult(y) Choice (BOI21_books)C++17
0 / 100
2 ms1104 KiB
#include<bits/stdc++.h> #include"books.h" using namespace std; long long x[100000 + 1] = {0}; long long h(int j,int k){ long long sm1 = 0; for (int i = j; i < j + k;i++){ if (x[i] == 0)x[i] = skim(i); sm1 += x[i]; } return sm1; } void solve(int N, int K, long long A, int S) { // cin >> N >> K >> S >> A; long long x[N + 1]; long long sm = 0; int f = 0; K--; for (int i = 1; i <= K;i++){ x[i] = skim(i); if (i <= K)sm += x[i]; } int l = K,r = N + 1; while (l + 1 < r){ int md = (l + r) / 2; if (x[md] == 0)x[md] = skim(md); if ((x[md] + sm) > 2ll * A)r = md; else l = md; } sm += x[l]; if (l == K or sm > 2LL * A)impossible(); if (sm >= A and sm <= 2LL * A){ vector<int>v; for (int j = 1; j <= K; j++){ v.push_back(j); } v.push_back(l); answer(v); } K++; l = 1,r = N - K + 2; while (l + 1 < r){ int md = (l + r) / 2; if (h(md,K) > 2ll * A)r = md; else l = md; } int d = 0; vector<int>v1; for (int i = l; i < l + K;i++){ if (x[i] == 0)x[i] = skim(i); d += x[i]; v1.push_back(i); } if (d < A or d > 2LL * A)impossible(); answer(v1); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:18:9: warning: unused variable 'f' [-Wunused-variable]
   18 |     int f = 0;
      |         ^
#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...