Submission #1281109

#TimeUsernameProblemLanguageResultExecution timeMemory
1281109KickingKunFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
70 ms5144 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define bigint __int128 #define emb emplace_back #define pb push_back #define pii pair <int, int> #define fi first #define se second #define all(v) v.begin(), v.end() #define Task "" #define MASK(k) (1ull << k) #define bitcnt(k) __builtin_popcount(k) #define testBit(n, k) ((n >> k) & 1) #define flipBit(n, k) (n ^ (1ll << k)) #define offBit(n, k) (n & ~MASK(k)) #define onBit(n, k) (n | (1ll << k)) template <class T> bool minimize(T &a, T b) {if (a > b) {a = b; return true;} return false;} template <class T> bool maximize(T &a, T b) {if (a < b) {a = b; return true;} return false;} const int N = 2e5 + 5, lim = 60, mod = 1e9 + 7; const ll INF = 1e18; int n, q, s, t, a[N], delta[N]; ll temp; ll cost(int x) { if (x < 0) return 1ll * x * s; return 1ll * x * t; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if (fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { delta[i] = a[i - 1] - a[i]; temp += cost(delta[i]); } while (q--) { int l, r, x; cin >> l >> r >> x; temp -= cost(delta[l]); delta[l] -= x; temp += cost(delta[l]); if (r < n) { temp -= cost(delta[r + 1]); delta[r + 1] += x; temp += cost(delta[r + 1]); } cout << temp << '\n'; } }

Compilation message (stderr)

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