Submission #1284054

#TimeUsernameProblemLanguageResultExecution timeMemory
1284054baotoan655Foehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
70 ms7276 KiB
#include <bits/stdc++.h> #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; #define int long long const int N = 2e5 + 5; int n, q, s, t; int a[N], diff[N]; int res = 0; void upd(int i, int d) { int val = diff[i]; if(val > 0) res -= d * s * val; else res += d * t * (-val); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); file("A") else file("task"); cin >> n >> q >> s >> t; for(int i = 0; i <= n; ++i) cin >> a[i]; for(int i = 1; i <= n; ++i) { diff[i] = a[i] - a[i - 1]; upd(i, 1); } for(int _ = 1; _ <= q; ++_) { int l, r, x; cin >> l >> r >> x; if(r + 1 <= n) upd(r + 1, -1); upd(l, -1); diff[r + 1] -= x; diff[l] += x; if(r + 1 <= n) upd(r + 1, 1); upd(l, 1); cout << res << '\n'; } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int32_t main()':
foehn_phenomena.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:19:5: note: in expansion of macro 'file'
   19 |     file("A") else file("task");
      |     ^~~~
foehn_phenomena.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:19:5: note: in expansion of macro 'file'
   19 |     file("A") else file("task");
      |     ^~~~
foehn_phenomena.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:19:20: note: in expansion of macro 'file'
   19 |     file("A") else file("task");
      |                    ^~~~
foehn_phenomena.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:19:20: note: in expansion of macro 'file'
   19 |     file("A") else file("task");
      |                    ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...