Submission #1030385

#TimeUsernameProblemLanguageResultExecution timeMemory
1030385vannnnnnnnAddk (eJOI21_addk)C++14
92 / 100
69 ms7440 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll a[100005], pre[100005], suf[100005], nom[100005]; int main() { ll n, k; scanf("%lld %lld", &n, &k); for(int i=1; i<=n; i++) { scanf("%d", &a[i]); pre[i]=pre[i-1]+(i*a[i]); nom[i]=nom[i-1]+a[i]; } for(int i=n; i>=1; i--)suf[i]=suf[i+1]+((n-i+1)*a[i]); int q; scanf("%d", &q); while(q--) { int que; scanf("%d", &que); if(que==1) { int blog; scanf("%d", &blog); } else { int l,r, m; scanf("%d %d %d", &l, &r, &m); ll len=r-l+1-m; ll ans=pre[l+len]-pre[l-1]; ans+=(suf[r-len]-suf[r+1]); ans+=((nom[r-len-1]-nom[l+len])*(len+1)); ans-=((nom[l+len]-nom[l-1])*(l-1)); ans-=((nom[r]-nom[r-len-1])*(n-r)); printf("%lld\n", ans); } } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:11:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   11 |   scanf("%d", &a[i]);
      |          ~^   ~~~~~
      |           |   |
      |           |   long long int*
      |           int*
      |          %lld
Main.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%lld %lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
Main.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
Main.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", &que);
      |   ~~~~~^~~~~~~~~~~~
Main.cpp:25:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |    scanf("%d", &blog);
      |    ~~~~~^~~~~~~~~~~~~
Main.cpp:30:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    scanf("%d %d %d", &l, &r, &m);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...