Submission #640004

# Submission time Handle Problem Language Result Execution time Memory
640004 2022-09-13T07:58:13 Z moday_morning Addk (eJOI21_addk) C++17
36 / 100
2000 ms 3664 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;
    vector <int> a(n+3);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int x;
        cin >> x;
        if (x == 1) {
            int ar[k+1];
            for (int i = 1; i <= k; i++) {
                cin >> ar[i];
            }
            vector <int> ns(k+3);
            int f = a[ar[1]];
            for (int i = 1; i < k; i++) {
                a[ar[i]] = a[ar[i+1]];
            }
            a[ar[k]] = f;
//            for (int i = 1; i <= n; i++) {
//                cout << a[i] << " ";
//            }
        }
        if (x == 2) {
            int l, r, m;
            cin >> l >> r >> m;
            int sum = 0, main = 0;
//            cout << "i: ";
            for (int i = l; i < l + m; i++) {
                sum += a[i];
//                cout << a[i] << " ";
            }
//            cout << "\n" << "sum: " << sum << " ";
            main += sum;
            for (int i = l + m; i <= r; i++) {
                sum -= a[i-m];
                sum += a[i];
//                cout << sum << " ";
                main += sum;
            }
            cout << main << "\n";
        }
    }
}


/*

8 3
7 2 5 1 9 3 4 6
3
2 2 7 4
1 2 5 8
2 2 7 3

 */

signed main() {
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 308 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 12 ms 308 KB Output is correct
5 Correct 18 ms 448 KB Output is correct
6 Correct 22 ms 468 KB Output is correct
7 Correct 29 ms 504 KB Output is correct
8 Correct 39 ms 680 KB Output is correct
9 Correct 68 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 278 ms 1100 KB Output is correct
2 Correct 443 ms 1596 KB Output is correct
3 Correct 777 ms 2064 KB Output is correct
4 Execution timed out 2084 ms 3424 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 965 ms 3068 KB Output is correct
2 Execution timed out 2078 ms 3664 KB Time limit exceeded
3 Halted 0 ms 0 KB -