Submission #1029813

#TimeUsernameProblemLanguageResultExecution timeMemory
1029813vjudge1Addk (eJOI21_addk)C++17
0 / 100
1698 ms2908 KiB
#include <bits/stdc++.h> using namespace std; #define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define str string #define pb push_back #define pf push_front #define nl "\n" #define ll long long // #define int long long #define all(v) (v).begin() , (v).end() #define rall(v) (v).rbegin(), (v).rend() #define ff first #define ss second #define len(a) a.size() #define pii pair<int,int> const int N = 50000 + 101; const int md = 998244353; const int MOD = 1e8; const int mega = 1e6 + 3; const int inf = 1e9; ll gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(int a, int b) { return (a / gcd(a, b)) * b; } void solve() { int n , k; cin >> n >> k; int a[n + 1]; for(int i = 1; i <= n; ++i)cin >> a[i]; int m; cin >> m; while(m--){ int ty; cin >> ty; if(ty == 2){ int l , r , m; cin >> l >> r >> m; int ans = 0; int pref[n + 1]; pref[0] = 0; for (int i = l; i <= r; ++i) pref[i] = pref[i - 1] + a[i]; for (int i = l; i <= r; ++i) { if (i <= r - m + 1) ans += pref[i + m - 1] - pref[i - 1]; } cout << ans << "\n"; } else{ vector<int>v(k + 1); for(int i = 1; i <= k; ++i)cin >> v[i]; int x = a[v[1]]; for(int i = 1; i < k; ++i) a[v[i]] = a[v[i + 1]]; a[v.back()] = x; } } } signed main() { SPEED; int t = 1; // cin >> t; while (t--) { solve(); } #ifndef ONLINE_JUDGE cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...