제출 #770769

#제출 시각아이디문제언어결과실행 시간메모리
770769That_Salamander휴가 (IOI14_holiday)C++14
0 / 100
27 ms5356 KiB
#include <bits/stdc++.h> #ifndef LOCAL_TEST #include "holiday.h" #endif #define FOR(var,bound) for(int var = 0; var < bound; var++) #define FORB(var,lb,ub) for (int var = lb; var < ub; var++) #define FORR(var,bound) for(int var = bound-1; var >= 0; var--) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pii; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { set<int> included; set<int> excluded; long long sum = 0; long long res = 0; for (int i = 0; i < min(d + 1, n); i++) { excluded.insert(attraction[i]); int canTake = d - i; while (included.size() > canTake) { auto it = included.begin(); excluded.insert(*it); sum -= *it; included.erase(it); } while (included.size() < canTake && excluded.size()) { auto it = (--excluded.end()); included.insert(*it); sum += *it; excluded.erase(*it); } while (included.size() && excluded.size() && *included.begin() < *(--excluded.end())) { int fromIncluded = *included.begin(); int fromExcluded = *(--excluded.end()); included.erase(included.begin()); excluded.erase(--excluded.end()); included.insert(fromExcluded); excluded.insert(fromIncluded); sum -= fromIncluded; sum += fromExcluded; } res = max(sum, res); } return res; } #ifdef LOCAL_TEST namespace hidden { int attraction[1000000]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, start, d; cin >> n >> start >> d; FOR(i, n) { cin >> hidden::attraction[i]; } cout << findMaxAttraction(n, start, d, hidden::attraction) << endl; } #endif

컴파일 시 표준 에러 (stderr) 메시지

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:29:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |         while (included.size() > canTake) {
      |                ~~~~~~~~~~~~~~~~^~~~~~~~~
holiday.cpp:36:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |         while (included.size() < canTake && excluded.size()) {
      |                ~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...