Submission #1116394

#TimeUsernameProblemLanguageResultExecution timeMemory
1116394staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
364 ms5948 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    vector<int64_t> amplitudes;
    int64_t temps[n + 1] = {0};
    int l, r, x, a = 0;
    cin >> x;
    a = x;
    amplitudes.push_back(x);
    for(int i = 1; i <= n; i++){
        cin >> x;
        amplitudes.push_back(x);
        a = x;
    }
    temps[0] = 0;
    for(int i = 1; i <= n; i++){
        if(amplitudes[i] < 0){
            temps[i] = temps[i - 1] - t * amplitudes[i];
        }else{
            temps[i] = temps[i - 1] - s * amplitudes[i];
        }
    }
    if(s != t){
        for(int k = 0; k < q; k++){
            cin >> l >> r >> x;
            for(int j = l; j <= r; j++){
                amplitudes[j] += x;
            }
            temps[0] = 0;
            for(int i = 1; i <= n; i++){
                if(amplitudes[i - 1] >= amplitudes[i]){
                    temps[i] = temps[i - 1] + t * (amplitudes[i - 1] - amplitudes[i]);
                }else{
                    temps[i] = temps[i - 1] - s * (amplitudes[i] - amplitudes[i - 1]);
                }
            }
            cout << temps[n] << endl;
        }
    }else{
        for(int k = 0; k < q; k++){
            cin >> l >> r >> x;
            temps[n] += x * t;
            if(r < n){
                temps[n] += x * t;
            }

            cout << temps[n] << endl;
        }
    }
}

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:12:18: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   12 |     int l, r, x, a = 0;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...