제출 #1050132

#제출 시각아이디문제언어결과실행 시간메모리
1050132manhlinh1501Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
81 ms11644 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; const int MAXN = 2e5 + 5; int N, Q; i64 S, T; i64 a[MAXN]; i64 ans = 0; i64 get(int p) { return a[p] > 0 ? -1LL * S * abs(a[p]) : 1LL * T * abs(a[p]); } void update(int p, int x) { if(p == 0 or p == N + 1) return; ans = ans - get(p); a[p] += x; ans = ans + get(p); } signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> Q >> S >> T; for(int i = 0; i <= N; i++) cin >> a[i]; for(int i = N; i >= 1; i--) a[i] = a[i] - a[i - 1]; for(int i = 1; i <= N; i++) ans += get(i); while(Q--) { int l, r, x; cin >> l >> r >> x; update(l, x); update(r + 1, -x); cout << ans << "\n"; } return (0 ^ 0); }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...