제출 #493099

#제출 시각아이디문제언어결과실행 시간메모리
493099KoyingFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
91 ms5720 KiB
#pragma region #pragma optimize("O3") #include <bits/stdc++.h> #define Weakoying ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define int long long #define pii pair<int, int> #define vi vector<int> #define vii vector<pair<int, int>> #define pqueue priority_queue #define pb push_back #define F first #define S second #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define cmax(a, b) a = (a > b ? a : b) #define cmin(a, b) a = (a < b ? a : b) #define put(x) cout << x << endl; #define putarr(x) for(int i = 0; i < sizeof(x); i++) cout << x[i] << (" \n")[i == sizeof(x) - 1]; #define stop system("pause"); #define MEM(x, n) memset(x, n, sizeof(x)); #define lowbit(x) x &(-x) #if !LOCAL #define endl "\n" #endif const int INF = 0x3f3f3f3f; const int P = 1e9+7; using namespace std; #pragma endregion /******************************************************************************/ #define MAXN 200005 #define MAXM 1000005 int n, q, s, t; int x[MAXN], pre[MAXN]; int f(int i) { int rtn = 0; if(i > 0) rtn -= i * s; else rtn -= i * t; return rtn; } void sol() { cin >> n >> q >> s >> t; for(int i = 0; i <= n; i++) { cin >> x[i]; if(i) pre[i] = x[i] - x[i - 1]; } int ans = 0; for(int i = 1; i <= n; i++) { ans += f(pre[i]); } // cout << ans << endl; int l, r, v; while(q--) { cin >> l >> r >> v; int tmp = (v > 0 ? 1 : -1); if(pre[l] > 0) { int after = pre[l] + v; if(after < 0) { ans += tmp * f(pre[l]); ans += tmp * f(-after); } else ans += tmp * f(abs(v)); pre[l] = after; } else // < 0 { int after = pre[l] + v; if(after > 0) { ans += -tmp * f(pre[l]); ans += tmp * f(after); } else ans += f(-abs(v)); pre[l] = after; } // cout << ans << " "; if(r == n) { cout << ans << endl; continue; } tmp = -tmp; if(pre[r + 1] > 0) { int after = pre[r + 1] - v; if(after < 0) { ans += tmp * f(pre[r + 1]); ans += tmp * f(-after); } else ans += tmp * f(abs(v)); pre[r + 1] = after; } else { int after = pre[r + 1] - v; if(after > 0) { ans += tmp * f(-pre[r + 1]); ans += tmp * f(after); } else ans += -tmp * f(-abs(v)); pre[r + 1] = after; } cout << ans << endl; } } signed main() { Weakoying; int t = 1; //while (cin >> t) { while (t--) { sol(); } } return 0; }

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

foehn_phenomena.cpp:1: warning: ignoring '#pragma region ' [-Wunknown-pragmas]
    1 | #pragma region
      | 
foehn_phenomena.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    2 | #pragma optimize("O3")
      | 
foehn_phenomena.cpp:29: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   29 | #pragma endregion
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...