제출 #287379

#제출 시각아이디문제언어결과실행 시간메모리
287379BeanZFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
137 ms13176 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 2e5 + 5; ll a[N], b[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("VietCT.INP", "r")){ freopen("VietCT.INP", "r", stdin); freopen("VietCT.OUT", "w", stdout); } ll n, q, s, t; cin >> n >> q >> s >> t; ll ans = 0; for (int i = 0; i <= n; i++){ cin >> a[i]; if (i > 0){ b[i] = a[i] - a[i - 1]; if (b[i] <= 0) ans = ans - b[i] * t; else ans = ans - b[i] * s; } } while (q--){ ll l, r, x; cin >> l >> r >> x; if (b[l] <= 0) ans = ans + b[l] * t; else ans = ans + b[l] * s; b[l] = b[l] + x; if (b[l] <= 0) ans = ans - b[l] * t; else ans = ans - b[l] * s; if (r != n){ if (b[r + 1] <= 0) ans = ans + b[r + 1] * t; else ans = ans + b[r + 1] * s; b[r + 1] = b[r + 1] - x; if (b[r + 1] <= 0) ans = ans - b[r + 1] * t; else ans = ans - b[r + 1] * s; } cout << ans << endl; } } /* */

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:13:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |                 freopen("VietCT.INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |                 freopen("VietCT.OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...