Submission #237021

#TimeUsernameProblemLanguageResultExecution timeMemory
237021crossing0verHoliday (IOI14_holiday)C++17
23 / 100
46 ms5888 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...