Submission #1071321

# Submission time Handle Problem Language Result Execution time Memory
1071321 2024-08-23T06:41:18 Z vjudge1 Addk (eJOI21_addk) C++17
36 / 100
2000 ms 3040 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define sz size
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fre(s) freopen(s".in", "r", stdin);freopen(s".out", "w", stdout);
#define s second
#define f first
#define ii pair<ll,ll>
const ll mod=1e9+7;
const int N=4e5+6;
const ll inf=1e12+5;      
ll n,k,d[N],g[N];
int main() 
{
    ios
    cin>>n>>k;
    for(int i=1;i<=n;++i)
    {
        cin>>d[i];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int x;
        cin>>x;
        if(x==1)
        {
          
            for(int i=0;i<k;++i)
            {
                cin>>g[i];
            }
            if(k>1)
            {
                ll h=d[g[0]];
                for(int i=0;i<k-1;i++)
                {
                    d[g[i]]=d[g[i+1]];
                }
                d[g[k-1]]=h;
            }
          
        }
        else
        {
            ll l,r,m;
            cin>>l>>r>>m;
            ll ans=0;
            if(r-l+1<m)
            {
                cout<<0<<"\n";
                continue;
            }
            for(int i=l;i<=r;++i)
            {
                ll cur=m;
                cur-=max(0ll,m-(i-l+1));
                cur-=max(0ll,m-(r-i+1));
                ans+=d[i]*cur;
            }
            cout<<ans<<endl;
        }
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 3 ms 2396 KB Output is correct
3 Correct 6 ms 2540 KB Output is correct
4 Correct 13 ms 2476 KB Output is correct
5 Correct 19 ms 2536 KB Output is correct
6 Correct 32 ms 3040 KB Output is correct
7 Correct 34 ms 2392 KB Output is correct
8 Correct 45 ms 2396 KB Output is correct
9 Correct 84 ms 2540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 329 ms 2644 KB Output is correct
2 Correct 696 ms 2900 KB Output is correct
3 Correct 1192 ms 2896 KB Output is correct
4 Execution timed out 2040 ms 2956 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1328 ms 2900 KB Output is correct
2 Execution timed out 2061 ms 2800 KB Time limit exceeded
3 Halted 0 ms 0 KB -