제출 #467855

#제출 시각아이디문제언어결과실행 시간메모리
467855JovanBA Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms288 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; using ll = long long; void solve(int N, int K, long long A, int S) { vector <pair <ll, int>> vals; int l = 1, r = N, gde = N+1; while(l <= r){ int mid = (l+r)/2; if(skim(mid) >= A){ r = mid - 1; gde = mid; } else l = mid + 1; } if(gde < K){ impossible(); return; } for(int i=1; i<=min(K, gde-1); i++) vals.push_back({skim(i), i}); ll sum = 0; if(gde <= N){ for(int i=0; i<K-1; i++) sum += vals[i].first; sum += skim(gde); if(A <= sum && sum <= 2*A){ vector <int> res; for(int j=0; j<K-1; j++) res.push_back(vals[j].second); res.push_back(gde); answer(res); return; } } for(int i=max(gde-K, K+1); i<gde; i++) vals.push_back({skim(i), i}); sum = 0; for(int i=0; i<K; i++) sum += vals[i].first; if(A <= sum && sum <= 2*A){ vector <int> res; for(int j=0; j<K; j++) res.push_back(vals[j].second); answer(res); return; } for(int i=K; i<vals.size(); i++){ sum -= vals[i-K].first; sum += vals[i].first; if(A <= sum && sum <= 2*A){ vector <int> res; for(int j=i-K+1; j<=i; j++) res.push_back(vals[j].second); answer(res); return; } } impossible(); }

컴파일 시 표준 에러 (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<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=K; i<vals.size(); i++){
      |                  ~^~~~~~~~~~~~
#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...