답안 #640005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640005 2022-09-13T07:59:26 Z moday_morning Addk (eJOI21_addk) C++17
36 / 100
2000 ms 2056 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() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
5 Correct 9 ms 340 KB Output is correct
6 Correct 12 ms 340 KB Output is correct
7 Correct 18 ms 436 KB Output is correct
8 Correct 23 ms 396 KB Output is correct
9 Correct 48 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 182 ms 732 KB Output is correct
2 Correct 392 ms 1020 KB Output is correct
3 Correct 681 ms 1124 KB Output is correct
4 Execution timed out 2074 ms 1992 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 827 ms 1132 KB Output is correct
2 Execution timed out 2078 ms 2056 KB Time limit exceeded
3 Halted 0 ms 0 KB -