제출 #1290029

#제출 시각아이디문제언어결과실행 시간메모리
1290029austinAddk (eJOI21_addk)C++20
36 / 100
2096 ms4552 KiB
#include <bits/stdc++.h> using namespace std; int16_t type; long long counter = 0, window; int n, k, q, l, r, m, i, j, temp; static inline long long read() { long long x = 0; int c = getchar_unlocked(); while ( c<'0' && c>'9') { c = getchar_unlocked(); } while (c>='0' && c<='9') { x = x*10+(c-'0'); c = getchar_unlocked(); } return x; } static inline void write(long long val) { if (val == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return; } char buf[21]; i=0; while (val>0) { buf[i++] = val%10+'0'; val/=10; } while (i--) { putchar_unlocked(buf[i]); } putchar_unlocked('\n'); } int main() { n = read(); k = read(); vector<long long> v(n+1), prefix(n+1, 0); vector<int> operations(k); for (i=1; i<=n; i++) { v[i] = read(); prefix[i] = prefix[i-1] + v[i]; } q = (int)read(); for (i=0; i<q; i++) { type = (int16_t)read(); if (type == 1) { for (j=0; j<k; j++) { operations[j] = (int)read(); } temp = v[operations[0]]; for (j=1; j<k; j++) { v[operations[j-1]] = v[operations[j]]; } v[operations[k-1]] = temp; temp = *min_element(operations.begin(), operations.end()); prefix[temp] = prefix[temp - 1] + v[temp]; for (j=temp+1; j<=n; ++j) { prefix[j] = prefix[j - 1] + v[j]; } } else if (type == 2) { l = read(); r = read(); m = read(); counter = 0; for (j=l; j<=r-m+1; j++) { counter += prefix[j+m-1] - prefix[j-1]; } write(counter); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...