Submission #500775

#TimeUsernameProblemLanguageResultExecution timeMemory
500775InternetPerson10Holiday (IOI14_holiday)C++17
23 / 100
453 ms5332 KiB
#include "holiday.h" #include <bits/stdc++.h> #include <bits/extc++.h> using namespace std; typedef long long ll; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll best = 0; // Try left ll ans = 0; multiset<int> s; int g = d; for(int i = start; i < n; i++) { ans += attraction[i]; s.insert(attraction[i]); while(g < s.size()) { auto it = s.begin(); ans -= *(it); s.erase(it); } g--; best = max(ans, best); if(g == 0) break; } multiset<int>().swap(s); // Try right g = d; ans = 0; for(int i = start; i >= 0; i--) { ans += attraction[i]; s.insert(attraction[i]); while(g < s.size()) { auto it = s.begin(); ans -= *(it); s.erase(it); } g--; best = max(ans, best); if(g == 0) break; } multiset<int>().swap(s); if(n <= 20) { // Subtask 1 for(int le = 0; le < start; le++) { ll ans = 0; int l = start - le; for(int i = le; i <= start; i++) { s.insert(attraction[i]); ans += attraction[i]; } for(int rr = start+1; rr < n; rr++) { int r = rr - start; s.insert(attraction[rr]); ans += attraction[rr]; int g = d - (l + r + min(l, r)); cout << g << '\n'; if(g <= 0) break; while(g < s.size()) { auto it = s.begin(); ans -= *(it); s.erase(it); } best = max(ans, best); } multiset<int>().swap(s); } return best; } else if(start == 0) { // Subtask 2 return best; } else if(n <= 3000) { // Subtask 3 for(int le = 0; le < start; le++) { cout << le << '\n'; ll ans = 0; int l = start - le; for(int i = le; i <= start; i++) { s.insert(attraction[i]); ans += attraction[i]; } for(int rr = start+1; rr < n; rr++) { int r = rr - start; s.insert(attraction[rr]); ans += attraction[rr]; int g = d - (l + r + min(l, r)); cout << g << '\n'; if(g <= 0) break; while(g < s.size()) { auto it = s.begin(); ans -= *(it); s.erase(it); } best = max(ans, best); } multiset<int>().swap(s); } return best; } // Subtask 4 return 0; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:17:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         while(g < s.size()) {
      |               ~~^~~~~~~~~~
holiday.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         while(g < s.size()) {
      |               ~~^~~~~~~~~~
holiday.cpp:58:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |                 while(g < s.size()) {
      |                       ~~^~~~~~~~~~
holiday.cpp:88:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::multiset<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |                 while(g < s.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...