# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1002452 |
2024-06-19T15:00:07 Z |
TitanicXDzz |
Pilot (NOI19_pilot) |
C++14 |
|
151 ms |
7620 KB |
#include<bits/stdc++.h>
using namespace std;
int a[1000010];
int l[1000010];
int r[1000010];
int dp[100010];
priority_queue<pair<int,int>> pq;
int main(){
int n,q;
cin>>n>>q;
l[0]=-1;
r[0]=1;
l[n+1]=n;
r[n+1]=n+2;
int maxi=0;
for(int i=1;i<=n;i++){
cin>>a[i];
l[i]=i-1;
r[i]=i+1;
pq.push({-a[i],-i});
if(a[i]>maxi)
maxi=a[i];
}
int sumi=0;
while(pq.empty()==0){
int x=pq.top().first;
int y=pq.top().second;
pq.pop();
int g=(r[-y]-r[-y-1])*(l[-y+1]-l[-y]);
sumi+=g;
l[r[-y-1]]=l[-y+1];
r[l[-y+1]]=r[-y-1];
dp[-x]=sumi;
}
for(int i=1;i<=n;i++){
if(dp[i]==0)
dp[i]=dp[i-1];
}
for(int i=0;i<q;i++){
int ans;
cin>>ans;
ans=min(ans,maxi);
cout<<dp[ans]<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
3364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
151 ms |
4640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
148 ms |
7620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |