# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
102935 | CaroLinda | Holiday (IOI14_holiday) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "holiday.h"
#define lp(i,a,b) for(int i=a;i<b;i ++)
#define MAXN 100005
#define pb push_back
#define pii pair<int,int>
#define ss second
#define ff first
#define lli long long int
using namespace std;
multiset<int> m ;
int resp ;
void tira()
{
resp -= *m.begin() ;
m.erase(m.begin()) ;
}
int sub_2 (int n, int start, int d,int a[])
{
resp = 0 ;
m.clear() ;
int best = -1 ;
lp(i, 0 ,min( d , n ))
{
m.insert(a[i]) ;
resp += a[i] ;
int k = m.size() ;
if( k - 1 > d - i )
tira() ;
if(k > d-i) tira() ;
best = max( best , resp ) ;
}
return best ;
}
int findMaxAttraction(int n, int start, int d,int a[])
{
return sub_2 (n,start,d,a) ;
}