Submission #749950

#TimeUsernameProblemLanguageResultExecution timeMemory
749950Abrar_Al_SamitHoliday (IOI14_holiday)C++17
47 / 100
5029 ms5324 KiB
#include <bits/stdc++.h> #include"holiday.h" using namespace std; int get(int i, int j, int x) { return j-i + min(x-i, j-x); } long long int findMaxAttraction(int n, int start, int d, int a[]) { if(d==0) return 0; long long ans = 0; for(int i=0; i<=start; ++i) { if(start-i>d) continue; multiset<int>list; long long cur = 0; for(int j=i; j<start; ++j) { list.insert(a[j]); cur += a[j]; } while(list.size()+start-i>d) { cur -= *list.begin(); list.erase(list.begin()); } for(int j=start; j<n && get(i, j, start)<d; ++j) { int travel_cost = get(i, j, start); if(travel_cost+list.size()>d) { cur -= *list.begin(); list.erase(list.begin()); } if(travel_cost+list.size()>d) { cur -= *list.begin(); list.erase(list.begin()); } if(travel_cost+list.size()<d) { list.insert(a[j]); cur += a[j]; } else { if(a[j]>*list.begin()) { cur -= *list.begin(); list.erase(list.begin()); cur += a[j]; list.insert(a[j]); } } ans = max(ans, cur); } } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:22:34: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |         while(list.size()+start-i>d) {
      |               ~~~~~~~~~~~~~~~~~~~^~
holiday.cpp:29:39: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |             if(travel_cost+list.size()>d) {
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
holiday.cpp:33:39: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |             if(travel_cost+list.size()>d) {
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
holiday.cpp:38:39: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |             if(travel_cost+list.size()<d) {
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...