# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
476025 |
2021-09-24T15:54:17 Z |
gvancak |
Addk (eJOI21_addk) |
C++14 |
|
2000 ms |
3228 KB |
#include <iostream>
using namespace std;
long long n,k,q,a[100001],p[100001],t,x,ans,l,r,m;
int main()
{
cin >> n >> k;
for (int i=1; i<=n; i++){
cin >> a[i];
p[i]=p[i-1]+a[i];
}
cin >> q;
for (int o=1; o<=q; o++){
cin >> t;
ans=0;
if (t==1){
for (int i=1; i<=k; i++){
cin >> x;
}
}
else{
cin >> l >> r >> m;
if (r-l+1<m*2-1){
x=r-(l+m-1)+1;
for (int i=l; i<=l+m-1-1; i++){
ans+=min(i-l+1,x)*a[i];
}
for (int i=l+m-1-1+1; i<=r; i++){
ans+=min(r-i+1,x)*a[i];
}
cout<<ans<<endl;
}
else{
x=m;
for (int i=l; i<=l+m-1-1; i++){
ans+=min(i-l+1,x)*a[i];
}
ans+=(p[r-m]-p[l+m-1-1])*m;
for (int i=r-m+1; i<=r; i++){
ans+=min(r-i+1,x)*a[i];
}
cout<<ans<<endl;
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
8 ms |
332 KB |
Output is correct |
4 |
Correct |
12 ms |
332 KB |
Output is correct |
5 |
Correct |
19 ms |
464 KB |
Output is correct |
6 |
Correct |
34 ms |
440 KB |
Output is correct |
7 |
Correct |
38 ms |
504 KB |
Output is correct |
8 |
Correct |
43 ms |
524 KB |
Output is correct |
9 |
Correct |
108 ms |
696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
263 ms |
880 KB |
Output is correct |
2 |
Correct |
536 ms |
1624 KB |
Output is correct |
3 |
Correct |
928 ms |
2272 KB |
Output is correct |
4 |
Execution timed out |
2072 ms |
3228 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
714 ms |
1648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |