Submission #641927

# Submission time Handle Problem Language Result Execution time Memory
641927 2022-09-17T22:50:32 Z glupan Addk (eJOI21_addk) C++14
0 / 100
287 ms 2988 KB
#include <bits/stdc++.h>
#define div /
#define ll long long

#define fore(i, l, r) for(int i=int(l); i<int(r); i++)
#define sz(a) int((a).size())
#define mod 1000000007

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    ll prefSum[n+5];
    memset(prefSum,0,sizeof prefSum);
    fore(i,0,n) {
        cin >> a[i];
        if(i>0)
            prefSum[i]+=prefSum[i-1];
        prefSum[i]+=a[i];
    }
    int q;
    cin >> q;
    while(q--) {
        int x; cin >> x;
        if(x==1) {
            int y; cin >> y;
        }
        else {
            int l,r,m;
            cin >> l >> r >> m;
            l--; r--;
            ll ans=m*(prefSum[r]-prefSum[l-1]);
            int cnt=min(m,r-l-m+2),temp=min((r-l+1) div 2,m-1);
            for(int i=temp; i>0; i--) {
                ans-=a[l-i+temp]*i;
                ans-=a[r-temp+i]*i;
            }
            cout << ans << endl;
        }
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:17: warning: unused variable 'cnt' [-Wunused-variable]
   35 |             int cnt=min(m,r-l-m+2),temp=min((r-l+1) div 2,m-1);
      |                 ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 1272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 287 ms 2988 KB Output isn't correct
2 Halted 0 ms 0 KB -