제출 #65088

#제출 시각아이디문제언어결과실행 시간메모리
65088keko37Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
359 ms169636 KiB
#include<iostream> #include<cstdio> using namespace std; typedef long long llint; const int MAXN = 200005; llint n, q, s, t, sol; llint l[MAXN], fen[MAXN]; void ubaci (int x, int k) { for (; x<MAXN; x+=x&-x) fen[x] += k; } llint upit (int x) { llint res = 0; for (; x; x-=x&-x) res += fen[x]; return res; } llint val (llint x, llint y) { if (x<y) return (x-y)*s; return (x-y)*t; } int main () { scanf("%lld%lld%lld%lld", &n, &q, &s, &t); for (int i=0; i<=n; i++) { scanf("%lld", &l[i]); if (!i) continue; sol += val(l[i-1], l[i]); ubaci(i, l[i]); ubaci(i+1, -l[i]); } for (int i=0; i<q; i++) { llint lef, rig, d; scanf("%lld%lld%lld", &lef, &rig, &d); sol -= val(upit(lef-1), upit(lef)); if (rig < n) sol -= val(upit(rig), upit(rig+1)); ubaci(lef, d); if (rig < n) ubaci(rig+1, -d); sol += val(upit(lef-1), upit(lef)); if (rig < n) sol += val(upit(rig), upit(rig+1)); printf("%lld\n", sol); } return 0; }

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

foehn_phenomena.cpp: In function 'llint val(llint, llint)':
foehn_phenomena.cpp:24:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (x<y) return (x-y)*s; return (x-y)*t;
  ^~
foehn_phenomena.cpp:24:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if (x<y) return (x-y)*s; return (x-y)*t;
                           ^~~~~~
foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld%lld", &n, &q, &s, &t);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &l[i]);
   ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", &lef, &rig, &d);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...