# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1029813 |
2024-07-21T11:03:59 Z |
vjudge1 |
Addk (eJOI21_addk) |
C++17 |
|
1698 ms |
2908 KB |
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define ll long long
// #define int long long
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
#define len(a) a.size()
#define pii pair<int,int>
const int N = 50000 + 101;
const int md = 998244353;
const int MOD = 1e8;
const int mega = 1e6 + 3;
const int inf = 1e9;
ll gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(int a, int b) {
return (a / gcd(a, b)) * b;
}
void solve() {
int n , k;
cin >> n >> k;
int a[n + 1];
for(int i = 1; i <= n; ++i)cin >> a[i];
int m;
cin >> m;
while(m--){
int ty;
cin >> ty;
if(ty == 2){
int l , r , m;
cin >> l >> r >> m;
int ans = 0;
int pref[n + 1];
pref[0] = 0;
for (int i = l; i <= r; ++i) pref[i] = pref[i - 1] + a[i];
for (int i = l; i <= r; ++i) {
if (i <= r - m + 1) ans += pref[i + m - 1] - pref[i - 1];
}
cout << ans << "\n";
}
else{
vector<int>v(k + 1);
for(int i = 1; i <= k; ++i)cin >> v[i];
int x = a[v[1]];
for(int i = 1; i < k; ++i) a[v[i]] = a[v[i + 1]];
a[v.back()] = x;
}
}
}
signed main() {
SPEED;
int t = 1;
// cin >> t;
while (t--) {
solve();
}
#ifndef ONLINE_JUDGE
cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Incorrect |
5 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
372 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1698 ms |
2908 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |