Submission #482195

# Submission time Handle Problem Language Result Execution time Memory
482195 2021-10-23T15:29:45 Z aris12345678 Addk (eJOI21_addk) C++14
92 / 100
65 ms 6188 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]+1LL*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 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 4 ms 588 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 6 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 944 KB Output is correct
2 Correct 17 ms 2004 KB Output is correct
3 Correct 21 ms 2636 KB Output is correct
4 Correct 38 ms 4420 KB Output is correct
5 Correct 60 ms 6188 KB Output is correct
6 Correct 65 ms 5924 KB Output is correct
7 Correct 55 ms 5920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 2028 KB Output isn't correct
2 Halted 0 ms 0 KB -