Submission #482186

# Submission time Handle Problem Language Result Execution time Memory
482186 2021-10-23T15:09:43 Z aris12345678 Addk (eJOI21_addk) C++14
0 / 100
33 ms 3480 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);
            ll ans = 0;
            m = min(r-l-m+2, m);
            ll a = (pref2[l+m-1]-pref2[l-1])-(pref1[l+m-1]-pref1[l-1])*(l-1);
            ll b = (pref1[r-m]-pref1[l+m-1])*m;
            ll c = (pref1[r]-pref1[r-m])*(r+1)-(pref2[r]-pref2[r-m]);
            printf("%lld\n", a+b+c);
        }
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:26:16: warning: unused variable 'ans' [-Wunused-variable]
   26 |             ll ans = 0;
      |                ^~~
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 304 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Incorrect 2 ms 460 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 1452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 3480 KB Output isn't correct
2 Halted 0 ms 0 KB -