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 ;
}
long long int findMaxAttraction(int n, int start, int d,int a[])
{
return sub_2 (n,start,d,a) * 1LL ;
}
Compilation message (stderr)
grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
int i, n_s;
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |