Submission #432791

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4327912021-06-18 13:23:10REALITYNBHoliday (IOI14_holiday)C++17
24 / 100
5086 ms5256 KiB
#include <bits/stdc++.h>
#include "holiday.h"
using namespace std;
long long findMaxAttraction(int n , int start , int d , int* a){
#define int long long
int ans = 0 ;
for(int i=start;i<n;i++){
multiset<int> el ;
for(int j=start;j<=i;j++) el.insert(a[j]) ;
int sum = 0;
int rest = d-(i-start) ;
if(rest<0) break ;
while(el.size()>rest)
el.erase(el.begin());
for(int x: el) sum+=x ;
ans=max(ans,sum) ;
// cout << i << " "<< sum << endl ;
for(int j=start-1;j>-1;--j){
rest = d-(min(start-j,i-start)*2+max(start-j,i-start));
//cout << i << " "<< j << " "<< rest << endl ;
if(rest<0) break ;
el.insert(a[j]) ;
sum+=a[j] ;
while(el.size()>rest){
sum-=*el.begin();
el.erase(el.begin()) ;
}
//cout << i << " "<< j << " "<< rest << " " << sum << endl ;
ans=max(ans,sum) ;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

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