Submission #1034947

#TimeUsernameProblemLanguageResultExecution timeMemory
1034947christinelynnAddk (eJOI21_addk)C++17
36 / 100
2081 ms4212 KiB
#include<bits/stdc++.h> /* Pragmaaa */ #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") /* Primitive Data */ #define ll long long #define db double /* Pair Macro */ #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define sc second /* Vector Macro */ #define vi vector<int> #define vll vector<ll> #define pb push_back #define ppb pop_back() #define pf push_front #define ppf pop_front() /* All Rounder */ #define all(x) x.begin(),x.end() #define forn(i,n) for(long long i = 1; i<= n; i++) #define for0(i,n) for(long long i = 0; i < n; i++) #define INF 1e9 #define LLINF 1e18 #define nl '\n' #define tab ' ' // Hati-hati kalau mau ngeflush tapi endl jadi nya '\n' #define flushmanual ios_base::sync_with_stdio(false); cin.tie(NULL) /* Modulo Fuctions */ const ll MOD = 1e9+7; ll tambah(ll a, ll b){ return (a+b)%MOD; } ll kurang(ll a, ll b){ return (((a - b) % MOD) + MOD) % MOD; } ll mul(ll a, ll b){ return ((a%MOD) * (b%MOD))%MOD; } /* debuggin */ #define debugl cout<<"Here\n" #define debug(awok) cout<<(awok)<<endl /* stuff you should look for * int overflow, array bounds * special cases (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH (TRY DP INSTEAD OF GREEDY AND VICE VERSA)(DONT FORGET SORTING) * TRY ALL STRATEGIES * DO NOT READ EDITORIALS BEFORE TRYING REALLY HARD! * careful references in recursion * careful copying when doing vectors esp in loops and functions * careful long long int and mod always OMG * careful return types of std such as int(ceil) * WATCH OUT GOING OVER MAX thru operations spam mod * vectors overflow arrays do NOT * cout endl lol * lower bound is first greater or equal * upper is first greater * if TLE play around with compiler * use static is helpful!! * take note of test stuff that need to be changed before submission * careful when u use garbage from abroad * careful modeling stuff as num going below 0 above n * number theory infinite due to multple of each other * careful not finding stuff in dictionaries * stupid cout precision and sci notations * in sets, rbegin() or --end() for last * careful multiset removal just use heapp * no segment trees if partial mins are needed, use sparse table * in combinatorics log matters esp in that dp, and think v carefully * NEVER INPUT DOUBLES * fraction class or multiplication tricks? * omg dont forget to flush when debugging * watch out for bitwise operations order of operations * PQ Greater top is smallest and Less top is largest * IF MOD JUST MINUS IF NOT MUCH INCREASE * IF MOD REQUIRED THEN USE CONST LL */ using namespace std; ll n,k,q; ll arr[100099]; void typ2(ll l, ll r, ll m){ ll ans = 0,sum = 0; for(int i = l; i <= r ; i++){ sum += arr[i]; if(i - m >= l){ sum -= arr[i-m]; } if(i >= l + m -1){ // cout << i << ' ' << sum << nl; ans += sum; } } cout << ans << nl; } int main(){ cin >> n >> k; forn(i,n)cin >> arr[i]; cin >> q; ll ii[k+5]; forn(i,q){ ll t; cin >> t; if(t == 1){ forn(j,k) cin >> ii[j]; ll f = arr[ii[1]]; for(int j = 2; j<=k; j++){ arr[ii[j-1]] = arr[ii[j]]; } arr[ii[k]] = f; }else{ ll a,b,c; cin >> a >> b >> c; typ2(a,b,c); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...