Submission #129295

#TimeUsernameProblemLanguageResultExecution timeMemory
129295souhhcongFoehn Phenomena (JOI17_foehn_phenomena)C++14
Compilation error
0 ms0 KiB
#include <iostream> using namespace std; #define int long long const int N = 2e5+5; int n, q, s, t; int l, r, val, sum_neg, sum_pos; int a[N], diff[N]; void update(int i, int val) { if (i < 0 || i >= n) return; if (diff[i] > 0 && diff[i] + val >= 0) { sum_pos += val; } else if (diff[i] > 0 && diff[i] + val < 0) { sum_pos -= diff[i]; sum_neg += (diff[i]+val); } else if (diff[i] <= 0 && diff[i]+val >= 0) { sum_neg -= diff[i]; sum_pos += diff[i]+val; } else if (diff[i] <= 0 && diff[i] + val < 0) { sum_neg += val; } diff[i] += val; } int main() { cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { diff[i] = a[i] - a[i+1]; if (diff[i] < 0) sum_neg += diff[i]; else sum_pos += diff[i]; } while(q--) { cin >> l >> r >> val; update(l-1,-val); update(r,val); cout << sum_neg*s + sum_pos*t << endl; } }

Compilation message (stderr)

foehn_phenomena.cpp:33:10: error: '::main' must return 'int'
 int main()
          ^