제출 #61030

#제출 시각아이디문제언어결과실행 시간메모리
61030gusfringFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
353 ms162632 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; typedef long long ll; ll bit[MAXN], A[MAXN], result; int N, Q, S, T; void updateP(int pos, int v){ while(pos <= N){ bit[pos] += v; pos += (pos&(-pos)); } } void update(int lo, int hi, int v){ updateP(lo, v); updateP(hi + 1, -v); } ll query(int pos){ ll res = A[pos]; for(; pos>0; pos-=(pos&(-pos))) res += bit[pos]; return res; } ll val(ll a, ll b){ if(a < b) return (a - b) * S; return (a - b) * T; } int main(){ scanf("%d %d %d %d", &N, &Q, &S, &T); for(int i=0; i<=N; ++i) scanf("%lld", &A[i]); for(int i=0; i<N; ++i) result += val(A[i], A[i + 1]); while(Q--){ int l, r, v; scanf("%d %d %d", &l, &r, &v); result -= val(query(l - 1), query(l)); if(r < N) result -= val(query(r), query(r + 1)); update(l, r, v); result += val(query(l - 1), query(l)); if(r < N) result += val(query(r), query(r + 1)); printf("%lld\n", result); } return 0; }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d", &N, &Q, &S, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:32:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<=N; ++i) scanf("%lld", &A[i]);
                          ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &l, &r, &v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...