Submission #435881

#TimeUsernameProblemLanguageResultExecution timeMemory
435881kderyloA Difficult(y) Choice (BOI21_books)C++14
10 / 100
2 ms200 KiB
#include <iostream> #include <vector> #include "books.h" using namespace std; void solve(int N, int K, long long A, int S) { vector<long long>wektor; vector<int>wektor2; vector<int>res; long long x=A/(long long)K; if(A%(long long)K!=0) { x++; } int poczatek=1; int koniec=N; while (poczatek < koniec) { int srodek = (poczatek + koniec) / 2; if (skim(srodek)>=x) koniec = srodek; else poczatek = srodek + 1; } for(int i=max(1,poczatek-10); i<=min(N,poczatek+10); i++) { wektor.push_back(skim(i)); wektor2.push_back(i); } for(int i=0; i<(int)wektor.size(); i++) { long long suma=0; int licznik=0; for(int j=i; j<min(K+i,(int)wektor.size()); j++) { suma+=wektor[j]; licznik++; } if(suma>=A&&suma<=(2*A)&&licznik==K) { for(int j=i; j<min(K+i,(int)wektor.size()); j++) { res.push_back(wektor2[j]); } break; } } if(res.empty()) { impossible(); } else { answer(res); } }
#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...