제출 #315947

#제출 시각아이디문제언어결과실행 시간메모리
315947jjjFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
173 ms13176 KiB
#include <bits/stdc++.h> using namespace std; long long a[200010], b[200010]; int main() { int n, q; long long s, t, v = 0; scanf("%d%d%lld%lld", &n, &q, &s, &t); for(int i = 0; i <= n; i++) scanf("%lld", &a[i]); for(int i = 1; i <= n; i++) b[i] = a[i] - a[i - 1]; for(int i = 1; i <= n; i++) { if(b[i] > 0) v -= s * b[i]; else v -= t * b[i]; } while(q--) { int l, r; long long x; scanf("%d%d%lld", &l, &r, &x); if(b[l] > 0) v += s * b[l]; else v += t * b[l]; b[l] += x; if(b[l] > 0) v -= s * b[l]; else v -= t * b[l]; if(r != n) { if(b[r + 1] > 0) v += s * b[r + 1]; else v += t * b[r + 1]; b[r + 1] -= x; if(b[r + 1] > 0) v -= s * b[r + 1]; else v -= t * b[r + 1]; } printf("%lld\n", v); } return 0; }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d%d%lld%lld", &n, &q, &s, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:14:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  for(int i = 0; i <= n; i++) scanf("%lld", &a[i]);
      |                              ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |   scanf("%d%d%lld", &l, &r, &x);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...