# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1034947 |
2024-07-25T23:45:57 Z |
christinelynn |
Addk (eJOI21_addk) |
C++17 |
|
2000 ms |
4212 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
348 KB |
Output is correct |
4 |
Correct |
9 ms |
544 KB |
Output is correct |
5 |
Correct |
15 ms |
604 KB |
Output is correct |
6 |
Correct |
18 ms |
604 KB |
Output is correct |
7 |
Correct |
25 ms |
604 KB |
Output is correct |
8 |
Correct |
31 ms |
604 KB |
Output is correct |
9 |
Correct |
58 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
186 ms |
1256 KB |
Output is correct |
2 |
Correct |
409 ms |
1616 KB |
Output is correct |
3 |
Correct |
714 ms |
2132 KB |
Output is correct |
4 |
Correct |
1998 ms |
3664 KB |
Output is correct |
5 |
Execution timed out |
2027 ms |
3372 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
824 ms |
3152 KB |
Output is correct |
2 |
Execution timed out |
2081 ms |
4212 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |