제출 #1071288

#제출 시각아이디문제언어결과실행 시간메모리
1071288vjudge1Addk (eJOI21_addk)C++17
0 / 100
2064 ms3292 KiB
#include <iostream> #include <vector> using namespace std; using ll = long long int; const int N = 100002; ll n, K; int a[N]; int main() { cin >> n >> K; for (int i = 1; i <= n; ++i) cin >> a[i]; int q; cin >> q; for (int tc = 1; tc <= q; ++tc) { int op; cin >> op; if (op == 1) { int x, prev, val; cin >> x; prev = x, val = a[x]; for (int i = 2; i < K; ++i) { cin >> x; a[prev] = a[x]; prev = x; } cin >> x; a[prev] = a[x]; a[x] = val; } else { int l, r, m; cin >> l >> r >> m; ll sum = 0, ans = 0; for (int i = l; i < l + m; ++i) sum += a[i]; ans += sum; //cout << sum << '\n'; int tl = l, tr = l + m - 1; while (tr < r) { sum -= a[tl++]; sum += a[++tr]; ans += sum; //cout << sum << '\n'; } cout << ans << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...