Submission #1154311

#TimeUsernameProblemLanguageResultExecution timeMemory
1154311CrabCNHFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> #define task "BriantheCrab" #define int long long #define pii pair <int, int> #define fi first #define se second #define szf sizeof #define sz(s) (int)((s).size()) using namespace std; template <class T> void mini (T &t, T f) {if (t > f) t = f;} template <class T> void maxi (T &t, T f) {if (t < f) t = f;} const int maxN = 2e5 + 5; const int inf = 1e18 + 7; const int mod = 1e9 + 7; int n, q, S, T; int a[maxN], d[maxN]; int res = 0; int add (int x, int t) { res += x * (x < 0 ? S : T) * (t ? 1 : -1); } void update (int i, int x) { add (d[i], 0); d[i] += x; add (d[i], 1); } void solve () { cin >> n >> q >> S >> T; cin >> a[0]; for (int i = 1; i <= n; i ++) { cin >> a[i]; d[i] = a[i - 1] - a[i]; add (d[i], 1); } while (q --) { int l, r, x; cin >> l >> r >> x; update (l, -x); if (r < n) { update (r + 1, x); } cout << res << '\n'; } } signed main () { cin.tie (nullptr) -> sync_with_stdio (false); if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int t = 1; //cin >> t; while (t --) { solve (); } return 0; } // thfdgb

Compilation message (stderr)

foehn_phenomena.cpp: In function 'long long int add(long long int, long long int)':
foehn_phenomena.cpp:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:57:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:58:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...