제출 #977841

#제출 시각아이디문제언어결과실행 시간메모리
977841SmuggingSpunFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
113 ms10620 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; typedef long long ll; const int lim = 2e5 + 5; int n, q, s, t; ll ans = 0, bit[lim]; void update(int p, int x){ for(; p <= n; p += p & -p){ bit[p] += x; } } ll get(int p){ ll ans = 0; for(; p > 0; p -= p & -p){ ans += bit[p]; } return ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n >> q >> s >> t; int x; cin >> x; for(int i = 1, pre = 0; i <= n; i++, pre = x){ cin >> x; update(i, x - pre); if(pre < x){ ans -= 1LL * s * (x - pre); } else{ ans += 1LL * t * (pre - x); } } for(int _ = 0; _ < q; _++){ int l, r, x; cin >> l >> r >> x; int d = get(l - 1) - get(l); if(d < 0){ ans += 1LL * s * -d; } else{ ans -= 1LL * t * d; } if(r < n){ if((d = get(r) - get(r + 1)) < 0){ ans += 1LL * s * -d; } else{ ans -= 1LL * t * d; } } update(l, x); update(r + 1, -x); if((d = get(l - 1) - get(l)) < 0){ ans -= 1LL * s * -d; } else{ ans += 1LL * t * d; } if(r < n){ if((d = get(r) - get(r + 1)) < 0){ ans -= 1LL * s * -d; } else{ ans += 1LL * t * d; } } cout << ans << "\n"; } }

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

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