Submission #956956

#TimeUsernameProblemLanguageResultExecution timeMemory
956956AcanikolicAddk (eJOI21_addk)C++14
0 / 100
1764 ms1732 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define int long long using namespace std; const int N = 1e5 + 10; const int mod = 1e9 + 7; const int inf = 2e9 + 1; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,k; cin >> n >> k; vector<int>a(n + 1); for(int i = 1; i <= n; i++) cin >> a[i]; int q; cin >> q; while(q--) { int type; cin >> type; if(type == 1) { vector<int>b(k + 1); for(int i = 1; i <= k; i++) cin >> b[i]; vector<int>c(k + 1); for(int i = 1; i <= k - 1; i++) c[i] = b[i + 1]; c[k] = b[1]; vector<int>cpy = a; for(int i = 1; i <= k; i++) cpy[b[i]] = a[c[i]]; a = cpy; }else { int l,r,res = 0,m; cin >> l >> r >> m; for(int i = l; i <= r; i++) { int wtf = min(i - l + 1,min(m,r - i + 1)); res += wtf * a[i]; } cout << res << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...