Submission #586251

#TimeUsernameProblemLanguageResultExecution timeMemory
586251TekorHoliday (IOI14_holiday)C++17
23 / 100
35 ms7756 KiB
#include"holiday.h"

#include <bits/stdc++.h>
using namespace std;
#define pii pair <int,int>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ll long long
#define pll pair <ll,ll>
const int N = 3e5 + 100;
long long int findMaxAttraction(int n, int start, int d, int a[]) {
	set <pll> q;
	ll sum = 0,ans = 0;
    for(int i = 0;i < n;i++) {
    	q.insert(mp(a[i],i));
    	sum += a[i];
    	int ost = d - i;
    	while(q.size() > ost) {
    		pll vv = *(q.begin());
    		q.erase(vv);
    		sum -= vv.f;
		}
		ans = max(ans,sum);
	}
	return ans;
}

Compilation message (stderr)

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