제출 #770764

#제출 시각아이디문제언어결과실행 시간메모리
770764That_Salamander휴가 (IOI14_holiday)C++14
0 / 100
34 ms5324 KiB
#include <bits/stdc++.h> #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())) { included.insert(*excluded.rbegin()); sum += *excluded.rbegin(); excluded.insert(*included.begin()); sum -= *included.begin(); included.erase(included.begin()); excluded.erase(--excluded.end()); } 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:25:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         while (included.size() > canTake) {
      |                ~~~~~~~~~~~~~~~~^~~~~~~~~
holiday.cpp:32:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |         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...