제출 #960438

#제출 시각아이디문제언어결과실행 시간메모리
960438AeonARYFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
159 ms11856 KiB
#include <bits/stdc++.h> using namespace std; #define Task "DATA" #define ll long long #define pb push_back #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FOD(i, a, b) for (int i = (a); i >= (b); i--) const int N = 1e6 + 6; const int INF = 1e9; const int MOD = 1e9 + 7; int n, q; ll s, t; ll a[N], fen[N]; void update(int idx, int val) { while (idx < N) { fen[idx] += val; idx += (idx & -idx); } } ll get(int idx) { ll res = 0; while (idx >= 1) { res += fen[idx]; idx -= (idx & -idx); } return res; } ll cost(int x, int y) { return (y > x ? -s * (y - x) : t * (x - y)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(Task".INP", "r")) { freopen(Task".INP", "r", stdin); freopen(Task".OUT", "w", stdout); } cin >> n >> q >> s >> t; FOR(i, 0, n) cin >> a[i]; ll ans = 0; FOR(i, 1, n) { update(i, a[i]); update(i + 1, -a[i]); ans += cost(a[i - 1], a[i]); } while (q--) { int l, r, x; cin >> l >> r >> x; ans -= cost(get(l - 1), get(l)); update(l, x); ans += cost(get(l - 1), get(l)); if (r + 1 <= n) { ans -= cost(get(r), get(r + 1)); update(r + 1, -x); ans += cost(get(r), get(r + 1)); } cout << ans << "\n"; } return 0; }

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

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