Submission #979893

#TimeUsernameProblemLanguageResultExecution timeMemory
979893peraFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
444 ms13176 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int N = 2e5 + 1; main(){ int n , q , S , T , sum = 0; cin >> n >> q >> S >> T; vector<int> A(n + 1) , d(n + 1); auto value = [&](int x){ return -d[x] * (d[x] > 0 ? S : T); }; for(int i = 0;i <= n;i ++){ cin >> A[i]; if(i > 0){ d[i] = A[i] - A[i - 1]; sum += value(i); } } while(q--){ int l , r , x; cin >> l >> r >> x; sum -= value(l); d[l] += x; sum += value(l); if(r < n){ sum -= value(r + 1); d[r + 1] -= x; sum += value(r + 1); } cout << sum << endl; } }

Compilation message (stderr)

foehn_phenomena.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...