제출 #1144217

#제출 시각아이디문제언어결과실행 시간메모리
1144217minggaFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
88 ms7240 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int mod = 1e9 + 7; const int inf = 2e18; const int N = 2e5 + 7; int n, q, s, t, a[N], d[N]; int calc(int x) { return x <= 0 ? -x * t : -s * x; } signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n >> q >> s >> t; int cur = 0; for(int i = 0; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) { d[i] = a[i] - a[i - 1]; cur += (calc(a[i] - a[i - 1])); // cout << a[i] - a[i - 1] << ' ' << calc(a[i] - a[i - 1]) << ln; } // cout << cur << ln; for(int i = 1; i <= q; i++) { int l, r, x; cin >> l >> r >> x; cur -= calc(d[l]); d[l] += x; cur += calc(d[l]); if(r < n) { cur -= calc(d[r + 1]); d[r + 1] -= x; cur += calc(d[r + 1]); } cout << cur << ln; } cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

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

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