Submission #1287224

#TimeUsernameProblemLanguageResultExecution timeMemory
1287224TrieTrFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
1095 ms2936 KiB
#include<bits/stdc++.h> using namespace std; void local() { #define taskname "" if(fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } } #define ll long long #define fi first #define se second #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); template <class X, class Y> bool mini(X& x, Y y) {return x > y ? x = y, true : false;} template <class X, class Y> bool maxi(X& x, Y y) {return x < y ? x = y, true : false;} const int N = 1e6 + 5; struct FenwickTree { using T = ll; vector<T>bit; int n; void init(int n_) { bit.assign((n = n_) + 5, 0); } void update(int id, int x) { for(; id <= n; id += id & -id) bit[id] += x; } T get(int id) { if(id <= 0) return 0; T sum = 0; for(; id; id -= id & -id) sum += bit[id]; return sum; } T getRan(int l, int r) { return get(r) - get(l - 1); } } fen; ll res = 0; int n, q, a[N], s, t; ll pls_cal(int x, int y) { if(x < y) return -1ll * s * (y - x); return 1ll * t * (x - y); } int main() { fastio; local(); cin >> n >> q >> s >> t; for(int i = 1; i <= n + 1; i++) cin >> a[i]; for(int i = 1; i <= n; i++) { res += pls_cal(a[i], a[i + 1]); } fen.init(n + 1); for(int _ = 1; _ <= q; _++) { int l, r, x; cin >> l >> r >> x; l++; r++; ll res = 0; for(int i = l; i <= r; i++) a[i] += x; for(int i = 1; i <= n; i++) { res += pls_cal(a[i], a[i + 1]); } cout << res << '\n'; } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'void local()':
foehn_phenomena.cpp:7:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:8:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |                 freopen(taskname".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...