제출 #640935

#제출 시각아이디문제언어결과실행 시간메모리
640935maks007Addk (eJOI21_addk)C++14
56 / 100
59 ms5964 KiB
#include "bits/stdc++.h" #define int long long signed main () { int n, k; scanf("%lld%lld", &n, &k); int a[n+1]; for(int i = 1; i <= n; i ++) scanf("%lld", &a[i]); int pref[n+1]; pref[1] = a[1]; for(int i = 2; i <= n; i ++) pref[i] = pref[i - 1] + a[i]; int up[n+1]; up[1] = a[1]; for(int i = 2; i <= n; i ++) up[i] = up[i - 1] + a[i] * i; int suff[n+2]; memset(suff, 0, sizeof(suff)); suff[n] = a[n]; for(int i = n - 1; i >= 1; i --) suff[i] = suff[i + 1] + a[i]; int down[n+2]; memset(down, 0, sizeof(down)); down[n] = a[n]; for(int i = n - 1; i >= 1; i --) down[i] = down[i + 1] + a[i] * (n-i+1); int q; scanf("%lld", &q); while(q --) { int type; scanf("%lld", &type); if(type == 1) { int kk = k, x; while(kk --) scanf("%lld", &x); }else { int l, r, m; scanf("%lld%lld%lld", &l, &r, &m); if(m == 1) { printf("%lld\n", pref[r] - pref[l-1]); continue; } int L = std::min(l+m-2,r-m), R = std::max(l+m,r-m+2); printf("%lld\n",((pref[R-1] - pref[L]) * (L+2-l)) + (up[L] - up[l-1] - (l-1)*(pref[L] - pref[l-1])) + (down[R] - down[r+1] - (n-r)*(suff[R] - suff[r+1]))); } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |  scanf("%lld%lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:7:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  for(int i = 1; i <= n; i ++) scanf("%lld", &a[i]);
      |                               ~~~~~^~~~~~~~~~~~~~~
Main.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  scanf("%lld", &q);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%lld", &type);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:29:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |    while(kk --) scanf("%lld", &x);
      |                 ~~~~~^~~~~~~~~~~~
Main.cpp:32:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |    scanf("%lld%lld%lld", &l, &r, &m);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...