#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;
ll findMaxAttraction(int n, int s, int d, int a[]){
ll ans=0;
if(s==0){
set<ll> st;
ll cur=0;
ll siz=0;
for(ll i=0;i<n;i++){
if(d<=0) break;
st.insert(a[i]);
cur+=a[i];
siz++;
while(siz>d){
cur-=*st.begin();
st.erase(st.begin());
siz--;
}
ans=max(ans, cur);
d--;
}
}
return ans;
}
/*int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll a[5]={10, 2, 20, 30, 1};
cout<<findMaxAttraction(5, 0, 7, a);
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
860 KB |
Output is correct |
2 |
Correct |
7 ms |
860 KB |
Output is correct |
3 |
Correct |
7 ms |
860 KB |
Output is correct |
4 |
Correct |
7 ms |
860 KB |
Output is correct |
5 |
Execution timed out |
5067 ms |
860 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1628 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |