# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
857025 |
2023-10-05T09:08:00 Z |
StefanSebez |
Fire (JOI20_ho_t5) |
C++14 |
|
412 ms |
18136 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
signed main()
{
int n,q;cin>>n>>q;
int a[n+1];for(int i=1;i<=n;i++)cin>>a[i];
vector<int>mono;
int R[n+50];
for(int i=1;i<=n;i++)
{
R[i]=n+1;
while(!mono.empty() && a[mono.back()]<a[i])
{
R[mono.back()]=i;
mono.pop_back();
}
mono.pb(i);
}
/*for(int i=1;i<=n;i++)cout<<R[i]<<" ";
cout<<endl;*/
int l[q+1],r[q+1],t[q+1];
for(int i=1;i<=q;i++)
{
cin>>t[i]>>l[i]>>r[i];
/*int b[n+1]={0};for(int i=1;i<=n;i++)b[i]=a[i];
while(t--)
{
int c[n+1];
for(int i=1;i<=n;i++)c[i]=max(b[i],b[i-1]);
for(int i=1;i<=n;i++)b[i]=c[i];
}
int res=0;
for(int i=l;i<=r;i++) res+=b[i];
cout<<res<<endl;*/
}
for(int i=1;i<=n;)
{
int ct=t[1],j=i+1;
while(j<=n && j<R[i] && ct>0)
{
a[j]=a[i];
j++;
ct--;
}
i=j;
}
int pref[n+1]={0};
for(int i=1;i<=n;i++)
{
pref[i]=pref[i-1]+a[i];
}
for(int i=1;i<=q;i++)
{
cout<<pref[r[i]]-pref[l[i]-1]<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
399 ms |
15984 KB |
Output is correct |
3 |
Correct |
393 ms |
17912 KB |
Output is correct |
4 |
Incorrect |
412 ms |
18136 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
402 ms |
15184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
356 ms |
14956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |