제출 #209251

#제출 시각아이디문제언어결과실행 시간메모리
209251my99nFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
166 ms7544 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; // would this be overflow even for long long ? ? ? ll a[200100], del[200100], neg, pos; void handle (int l, int x) { if (del[l] < 0) neg -= del[l]; if (del[l] > 0) pos -= del[l]; del[l] = del[l]+x; if (del[l] < 0) neg += del[l]; if (del[l] > 0) pos += del[l]; } int main(){ int n, q; ll s, t; 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++) { del[i] = a[i]-a[i-1]; if (del[i] < 0) neg += del[i]; if (del[i] > 0) pos += del[i]; } while(q--) { int l, r, x; scanf("%d %d %d", &l, &r, &x); handle(l, x); if (r != n) handle(r+1, -x); printf("%lld\n", -pos*s-neg*t); } return 0; }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:17:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n, q; ll s, t; scanf("%d %d %lld %lld", &n, &q, &s, &t);
                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:18:39: 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:25:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int l, r, x; scanf("%d %d %d", &l, &r, &x);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...