Submission #482191

# Submission time Handle Problem Language Result Execution time Memory
482191 2021-10-23T15:15:45 Z aris12345678 Addk (eJOI21_addk) C++14
0 / 100
31 ms 1980 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int mxN = 1e5+5;
int a[mxN];
ll pref1[mxN], pref2[mxN];

int main() {
    int n, k, q;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        pref1[i] = 1LL*pref1[i-1]+a[i];
        pref2[i] = 1LL*pref2[i-1]+i*a[i];
    }
    scanf("%d", &q);
    while(q--) {
        int type, l, r, m;
        scanf("%d", &type);
        if(type == 1)
            scanf("%d", &l);
        else {
            scanf("%d %d %d", &l, &r, &m);
            m = min(r-l-m+2, m);
            ll a = 1LL*(pref2[l+m-1]-pref2[l-1])-1LL*(pref1[l+m-1]-pref1[l-1])*(l-1);
            ll b = 1LL*(pref1[r-m]-pref1[l+m-1])*m;
            ll c = 1LL*(pref1[r]-pref1[r-m])*(r+1)-1LL*(pref2[r]-pref2[r-m]);
            printf("%lld\n", a+b+c);
        }
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Main.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d", &type);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |             scanf("%d", &l);
      |             ~~~~~^~~~~~~~~~
Main.cpp:25:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |             scanf("%d %d %d", &l, &r, &m);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 2 ms 332 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1980 KB Output isn't correct
2 Halted 0 ms 0 KB -