# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863889 |
2023-10-21T10:39:24 Z |
FIFI_cpp |
Addk (eJOI21_addk) |
C++17 |
|
2000 ms |
4436 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <iomanip>
#define ll long long
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n,k;
cin >> n >> k;
ll nums[100000];
ll prefix[100001];
ll curr = 0;
for (int i = 0;i < n;i++)
{
cin >> nums[i];
curr += nums[i];
prefix[i + 1] = curr;
}
int q;
cin >> q;
while (q--)
{
int type;
cin >> type;
if (type == 1)
{
vector<ll> pos(k,0);
for (int i = 0;i < k;i++)
{
cin >> pos[i];
}
swap(nums[pos[0] - 1], nums[pos[k - 1] - 1]);
for (int i = 0;i < k - 2;i++)
{
swap(nums[pos[i] - 1], nums[pos[i + 1] - 1]);
}
ll s = 0;
for (int i = 0;i < n;i++)
{
prefix[i + 1] = s + nums[i];
s+=nums[i];
}
}
else
{
int begin,end,size;
cin >> begin >> end >> size;
int c_begin = begin;
int c_end = begin + size - 1;
ll curr_sum = 0;
while (c_end <= end)
{
curr_sum += prefix[c_end] - prefix[c_begin - 1];
c_end++;
c_begin++;
}
cout << curr_sum << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1884 KB |
Output is correct |
2 |
Correct |
2 ms |
2028 KB |
Output is correct |
3 |
Correct |
3 ms |
2032 KB |
Output is correct |
4 |
Correct |
4 ms |
1880 KB |
Output is correct |
5 |
Correct |
6 ms |
2124 KB |
Output is correct |
6 |
Correct |
9 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
2140 KB |
Output is correct |
8 |
Correct |
15 ms |
2180 KB |
Output is correct |
9 |
Correct |
29 ms |
2316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
3088 KB |
Output is correct |
2 |
Correct |
227 ms |
2892 KB |
Output is correct |
3 |
Correct |
419 ms |
3408 KB |
Output is correct |
4 |
Correct |
1630 ms |
4012 KB |
Output is correct |
5 |
Execution timed out |
2037 ms |
3932 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
973 ms |
3632 KB |
Output is correct |
2 |
Execution timed out |
2069 ms |
4436 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |