Submission #944048

#TimeUsernameProblemLanguageResultExecution timeMemory
944048thelegendary08A Difficult(y) Choice (BOI21_books)C++17
0 / 100
5 ms1236 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long ll; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // void solve(int N, int K, long long A, int S) { vector<long long int>v(N); for(int i = 1;i<=N;i++){ v[i-1] = skim(i); } ll sum = 0; for(int i = 0;i<K;i++){ sum += v[i]; } if(sum >= A && sum <= 2*A){ vector<int> ret; for(int i = 1;i<=K;i++){ ret.push_back(i); } answer(ret); } if(sum > 2*A)impossible(); int crit = -1; for(int i = 1;i<N - K + 1; i++){ sum -= v[i-1]; sum += v[i+K-1]; if(sum >= A && sum <= 2*A){ vector<int>ret; for(int j = i;j<i+K;j++)ret.push_back(j + 1); answer(ret); } if(sum >2*A){ crit = i; break; } } if(crit == -1)impossible(); else{ long long int s = 0; for(int i = crit - 1;i<crit+K;i++){ s += v[i]; } for(int i = crit-1;i<crit+K;i++){ if(s - v[i] <= 2*A && s-v[i] >= A){ vector<int>ret; for(int j = crit - 1;j<crit+K;j++){ if(j != i){ ret.push_back(j+1); } } answer(ret); } } } 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...