Submission #1041179

# Submission time Handle Problem Language Result Execution time Memory
1041179 2024-08-01T17:04:56 Z Jer Addk (eJOI21_addk) C++17
0 / 100
1257 ms 3520 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100'000;
int n, k, q;
long long A[MAXN];

int main(){
    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; i++)
        scanf("%lld", &A[i]);
    
    long t, l, r, m;
    long long res;

    scanf("%d", &q);
    vector<long long> out;
    for (int i = 0; i < q; i++){
        scanf("%ld", &t);

        if (t == (long)2){
            scanf("%ld %ld %ld", &l, &r, &m);
            res = 0, r--, l--;

            for (int i = l; i <= r; i++)
                res += (min({m - 1, i - l, r - i + 1}) + ((r - i + 1) >= m)) * A[i];
            out.push_back(res);
        }
        else
            for (int i = 0; i < k; i++)
                scanf("%ld", &l);

    }

    for (auto i : out)
        printf("%lld\n", i);

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld", &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("%ld", &t);
      |         ~~~~~^~~~~~~~~~~
Main.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |             scanf("%ld %ld %ld", &l, &r, &m);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:33:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |                 scanf("%ld", &l);
      |                 ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 307 ms 1616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1257 ms 3520 KB Output isn't correct
2 Halted 0 ms 0 KB -