Submission #967302

# Submission time Handle Problem Language Result Execution time Memory
967302 2024-04-21T18:33:01 Z Fikrat_Asadzadeh Addk (eJOI21_addk) C++14
36 / 100
2000 ms 5152 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FORI(i, n) for(int i = 0; i < n; i++)
#define FOR(i, n) for(int i = 1; i <= n; i++)
typedef vector < ll > vl; 
typedef set < ll > setl;
#define ff first
#define ss second    
#define all(v) v.begin(), v.end() 
#define pll pair < ll , ll > 
#define db  double
#define nll cout << "\n"
#define nl "\n"
#define sync                          \
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ;
// #define int ll
const ll INF = 1e9;
const int MAX = 1e5 + 5; 
ll n, m, k;
ll t[4 * MAX], a[MAX], b[11], pref[MAX];
void solve(){
    cin >> n >> k;
    FOR(i, n){
        cin >> a[i];
    }
    ll q, c;
    cin >> q;
    ll l, r, x;
    FOR(i, n)pref[i] = pref[i - 1] + a[i];
    while(q--){
        cin >> c;
        if(c == 2){
            cin >> l >> r >> x;
            ll res = 0; 
            for(ll i = l; i <= r; i++){
                if(i <= r- x + 1)
                res += max(0LL, pref[i + x - 1] - pref[i - 1]);
            }
            cout << res << nl;
        }   
        else{
            FOR(i, k){
                cin >> b[i];
            }
            x = a[b[1]];
            for(ll i = 1; i <= k - 1; i++)a[b[i]] = a[b[i + 1]];
            a[b[k]] = x;
        }
    }
}
signed main(){
    sync;
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}   
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2548 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 7 ms 2392 KB Output is correct
5 Correct 13 ms 2824 KB Output is correct
6 Correct 19 ms 2652 KB Output is correct
7 Correct 26 ms 2648 KB Output is correct
8 Correct 34 ms 2648 KB Output is correct
9 Correct 68 ms 2896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 261 ms 2896 KB Output is correct
2 Correct 579 ms 3804 KB Output is correct
3 Correct 1035 ms 4324 KB Output is correct
4 Execution timed out 2085 ms 5152 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1085 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -