답안 #1045121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045121 2024-08-05T17:05:27 Z Nickpapadak Addk (eJOI21_addk) C++14
92 / 100
944 ms 5716 KB
#include<bits/stdc++.h>
using namespace std;
const unsigned int MAXN = 1e+5 + 10;
#define ll long long
ll N, K, Q;
ll A[MAXN], ps[MAXN];
ll solveBF(){
    ll ans = 0;
    ll l,r,m;
    scanf("%lld%lld%lld",&l,&r,&m);
    for(ll i = l; i <= l+m-1;++i){
        ans += ps[l+m-1] - ps[i-1];
        // prllf("%d %d: %d\n",i,i+m,ans);
    }
    ans += (ps[r-m] - ps[l+m-1])*m;
    for(ll i = r-m+1; i <= r; ++i){
        ans += ps[i] - ps[r-m];
    }
    // ll re = l+m-1;
    // while(re <=r){
    //     ans += (ps[re]-ps[l-1]);
    //     l++;re++;
    // }
    return ans;
}

// int scanBF(){
//     int k;
//         // scanf("%d",&k);
//     return -1;
// }
 
// int BF(int typE){
//     if(typE == 1) return scanBF();
//     return solveBF();
// }
 
int main(){
    scanf("%lld%lld",&N,&K);
    ps[0] = 0;
    for(ll i =1;i<=N;++i){
        scanf("%lld", &A[i]);
        ps[i] = ps[i-1] + A[i];
    }
    scanf("%lld", &Q);
    while(Q--){
        ll b;
        scanf("%lld", &b);
        if(b == 2){
            printf("%lld\n", solveBF());
        }else{
            int x;
            scanf("%lld", &x);
        }
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:53:23: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   53 |             scanf("%lld", &x);
      |                    ~~~^   ~~
      |                       |   |
      |                       |   int*
      |                       long long int*
      |                    %d
Main.cpp: In function 'long long int solveBF()':
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld%lld%lld",&l,&r,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%lld%lld",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%lld", &A[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
Main.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     scanf("%lld", &Q);
      |     ~~~~~^~~~~~~~~~~~
Main.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         scanf("%lld", &b);
      |         ~~~~~^~~~~~~~~~~~
Main.cpp:53:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |             scanf("%lld", &x);
      |             ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 7 ms 556 KB Output is correct
7 Correct 11 ms 604 KB Output is correct
8 Correct 12 ms 648 KB Output is correct
9 Correct 23 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 872 KB Output is correct
2 Correct 204 ms 1104 KB Output is correct
3 Correct 337 ms 1620 KB Output is correct
4 Correct 655 ms 2332 KB Output is correct
5 Correct 944 ms 3920 KB Output is correct
6 Correct 928 ms 5716 KB Output is correct
7 Correct 753 ms 5456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 1292 KB Output isn't correct
2 Halted 0 ms 0 KB -