제출 #68214

#제출 시각아이디문제언어결과실행 시간메모리
68214almasalmasFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
797 ms7628 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int a[200001]; int d[200001]; main () { int n, q, s, t; cin >> n >> q >> s >> t; for (int i = 0;i <= n;i ++) cin >> a[i]; int cur = 0; for (int i = 1;i <= n;i ++) { int len = abs (a[i] - a[i - 1]); if (a[i] > a[i - 1]) { cur -= len * s; } else cur += len * t; } // cout << cur << endl; while (q --) { int l, r, x; cin >> l >> r >> x; if (r != n) { int X = a[r]; a[r] += d[r]; if (a[r] < a[r + 1]) { cur += s * (a[r + 1] - a[r]); } else cur -= t * (a[r] - a[r + 1]); d[r] += x; a[r] += x; if (a[r] < a[r + 1]) { cur -= s * (a[r + 1] - a[r]); } else cur += t * (a[r] - a[r + 1]); a[r] = X; } // cout << cur << endl; int X = a[l - 1]; a[l - 1] += d[l - 1]; if (a[l - 1] < a[l]) { cur += s * (a[l] - a[l - 1]); } else cur -= t * (a[l - 1] - a[l]); d[l - 1] -= x; a[l - 1] -= x; if (a[l - 1] < a[l]) { cur -= s * (a[l] - a[l - 1]); } else cur += t * (a[l - 1] - a[l]); a[l - 1] = X; cout << cur << endl; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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