Submission #1088980

#TimeUsernameProblemLanguageResultExecution timeMemory
1088980PiokemonA Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; // // --- 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) { int pocz,kon,srod; pocz=1; kon=N; while(pocz<kon){ srod=(pocz+kon)/2; if (skim(srod)>=A)kon=srod; else pocz=srod+1; } if (pocz<=K-1)impossible(); long long int wart = skim(pocz); vector<long long> val; vector<int> ind; for (int x=1;x<=min(K,pocz);x++)val.push_back(skim(x)); for (int x=max(K+1,pocz-K+1);x<=pocz;x++)val.push_back(skim(x)); for (int x=1;x<=min(K,pocz);x++)ind.push_back(x); for (int x=max(K+1,pocz-K+1);x<=pocz;x++)ind.push_back(x); long long suma=0; for (int x=0;x<K-1;x++)suma+=val[x]; suma+=wart; if (A<=suma && suma<=2*A){ vector<int> odp; for (int x=0;x<K-1;x++)odp.push_back(ind[x]); odp.push_back(pocz); answer(odp);return; } suma=0; for (int x=0;x<K;x++)suma+=val[x]; for (int x=K;x<val.size();x++){ if (A<=suma && suma<=2*A){ vector<int> odp; for (int y=x-K;y<x;y++)odp.push_back(ind[y]); answer(odp); return; } suma+=val[x]; suma-=val[x-K]; } if (A<=suma && suma<=2*A){ vector<int> odp; for (int y=val.size()-K;y<val.size();y++)odp.push_back(ind[y]); answer(odp); return; } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int x=K;x<val.size();x++){
      |                  ~^~~~~~~~~~~
books.cpp:55:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for (int y=val.size()-K;y<val.size();y++)odp.push_back(ind[y]);
      |                                 ~^~~~~~~~~~~
#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...