Submission #237021

# Submission time Handle Problem Language Result Execution time Memory
237021 2020-06-04T09:22:11 Z crossing0ver Holiday (IOI14_holiday) C++17
23 / 100
46 ms 5888 KB
#include<bits/stdc++.h>
#include"holiday.h"
#define ll long long 
#define fi first
#define se second
using namespace std;
int n,x,d,val[100005];
ll solve() {
	set <pair<int,int> >  s;
	ll eaten = 0,ans = val[x];
	int left = 0;
	eaten = val[x];
	s.insert({val[x],x});
	for (int i = x + 1; i < n; i++) {
		int stamina = i + s.size();
		if (i  >= d) {left = i + 1; break;}
		while (stamina >= d) {
			eaten -= (*s.begin()).fi;
			s.erase(s.begin());
				stamina--;	
		}
		if (stamina < d) {
			eaten += val[i];
			s.insert({val[i],i});
		}
		ans = max(ans,eaten);
	}    
	return ans;/*  
	for (int i = 0;)
	for (int i = x + 1; i > 0; i--) {
		
		
	}     */
		
		
		
		
	}

long long int findMaxAttraction(int n1, int start, int d1, int attraction[]) {
	n = n1;
	x = start;
	d = d1;
	for (int i = 0; i < n; i ++) val[i] = attraction[i];
	if (!d) return 0;
	if (d == 1) return val[start];
	return solve();

}

Compilation message

holiday.cpp: In function 'long long int solve()':
holiday.cpp:11:6: warning: variable 'left' set but not used [-Wunused-but-set-variable]
  int left = 0;
      ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 5888 KB Output is correct
2 Correct 37 ms 5760 KB Output is correct
3 Correct 37 ms 5752 KB Output is correct
4 Correct 38 ms 5752 KB Output is correct
5 Correct 46 ms 4144 KB Output is correct
6 Correct 15 ms 1920 KB Output is correct
7 Correct 25 ms 2944 KB Output is correct
8 Correct 28 ms 2936 KB Output is correct
9 Correct 12 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -