Submission #298062

#TimeUsernameProblemLanguageResultExecution timeMemory
298062mieszko11bHoliday (IOI14_holiday)C++14
23 / 100
5044 ms5760 KiB
#include "holiday.h" #include <bits/stdc++.h> using namespace std; using ll = long long; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll res = 0; vector<int> a(n); for(int i = 0 ; i < n ; i++) a[i] = attraction[i]; for(int t = 0 ; t < 2 ; t++) { for(int i = start ; i >= 0 ; i--) { ll sum = 0; multiset<int> S; int d2 = d - (start - i); for(int j = i ; j < n ; j++) { //~ cout << i << " " << j << endl; S.insert(a[j]); sum += a[j]; while(S.size() > d2 - (j - i)) { auto it = S.begin(); sum -= *it; S.erase(it); } res = max(res, sum); } } //~ reverse(a.begin(), a.end()); //~ start = n - start - 1; } return res; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:24:20: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     while(S.size() > d2 - (j - 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...