제출 #238728

#제출 시각아이디문제언어결과실행 시간메모리
238728xiryssFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1004 ms26468 KiB
//#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") /*#pragma GCC optimize("section-anchors") #pragma GCC optimize("profile-values,profile-reorder-functions,tracer") #pragma GCC optimize("vpt") #pragma GCC optimize("rename-registers") #pragma GCC optimize("move-loop-invariants") #pragma GCC optimize("unswitch-loops") #pragma GCC optimize("function-sections") #pragma GCC optimize("data-sections") #pragma GCC optimize("branch-target-load-optimize") #pragma GCC optimize("branch-target-load-optimize2") #pragma GCC optimize("btr-bb-exclusive")*/ //#pragma comment(linker, "/STACK:367077216") #define _CRT_SECURE_NO_WARNINGS #include <chrono> #include <set> #include <map> #include <deque> #include <string> #include <cstdint> #include <cmath> #include <queue> #include <cassert> #include <random> #include <bitset> #include <iomanip> #include <numeric> #include <time.h>////////////// #include <ctime> #include <string> #include <cstdio> #include <vector> #include <cstdlib> #include <iostream> #include <algorithm> #include <unordered_map> #include <unordered_set> //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ //#define endl '\n' #define mp make_pair #define pbc push_back #define pob pop_back() #define empb emplace_back #define queuel queue<long long> #define sqr(a) ((a) * (a)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define pin(p) cin >> p.first >> p.second; #define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin()); #define rev(v) reverse(v.begin(), v.end()); #define sout(s, c) for (auto i : s) cout << i << c; #define pout(p) cout << p.first << " " << p.second; #define er(v, l, r) erase(v.begin() + l, v.begin() + r); #define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i]; #define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c; #define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]); #define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL)) #define dab(v) for(auto i:v)cout<<i<<' '; #define sp system("pause") //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ using namespace std; //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ typedef long long ll; typedef long double ld; typedef unsigned long long ull; //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++ const ld EPS = 1e-9; const ld EPS2 = 1e-6; const ld PI = acos(-1); ll mod = (ll)81273918 * 10000000 + 3623713; const int MOD7 = 1000000007; const int MOD9 = 1000000009; const int a228 = 18; const int inf = 1e9; const ll kekmod = 1791791791; const ll bestmod = 1148822869; #define int ll int n, q, s, tt; const int MAXN = 2e5 + 228; int t[4 * MAXN][2]; void build(int v, int l, int r, vector<int> & a) { if (l == r - 1) { t[v][0] = a[l]; return; } build(2 * v + 1, l, (l + r) / 2, a); build(2 * v + 2, (l + r) / 2, r, a); } int add[4 * MAXN][2]; void push(int v, int tp, int l, int r) { if (l != r - 1) { add[2 * v + 1][tp] += add[v][tp]; add[2 * v + 2][tp] += add[v][tp]; } t[v][tp] += (r - l) * add[v][tp]; add[v][tp] = 0; } void upd(int v, int tp, int l, int r, int ql, int qr, int x) { push(v, tp, l, r); if (l >= qr || ql >= r) return; if (l >= ql && r <= qr) { add[v][tp] += x; push(v, tp, l, r); return; } upd(2 * v + 1, tp, l, (l + r) / 2, ql, qr, x); upd(2 * v + 2, tp, (l + r) / 2, r, ql, qr, x); t[v][tp] = t[2 * v + 1][tp] + t[2 * v + 2][tp]; } int get(int v, int tp, int l, int r, int ql, int qr) { push(v, tp, l, r); if (l >= qr || ql >= r) return 4e18 + 1; if (l >= ql && r <= qr) return t[v][tp]; int g1 = get(2 * v + 1, tp, l, (l + r) / 2, ql, qr); int g2 = get(2 * v + 2, tp, (l + r) / 2, r, ql, qr); return min(g1, g2); } signed main() { fastio(); cin >> n >> q >> s >> tt; vector<int> a(n + 1); vin(a); build(0, 0, a.size(), a); int tp = 0; upd(0, 1, 0, a.size(), 0, 1, 0); for (int i = 1; i <= n; ++i) { tp += (a[i] > a[i - 1] ? -(a[i] - a[i - 1]) * s : -(a[i] - a[i - 1]) * tt); upd(0, 1, 0, a.size(), i, i + 1, tp); } for (int i = 0; i < q; ++i) { int l, r, x; cin >> l >> r >> x; a[l] = get(0, 0, 0, a.size(), l, l + 1); a[l - 1] = get(0, 0, 0, a.size(), l - 1, l); int old = (a[l] > a[l - 1] ? -(a[l] - a[l - 1]) * s : -(a[l] - a[l - 1]) * tt); int now = (a[l] + x > a[l - 1] ? -(a[l] + x - a[l - 1]) * s : -(a[l] + x - a[l - 1]) * tt); upd(0, 1, 0, a.size(), l, a.size(), now - old); if (r < n) { a[r] = get(0, 0, 0, a.size(), r, r + 1); a[r + 1] = get(0, 0, 0, a.size(), r + 1, r + 2); old = (a[r + 1] > a[r] ? -(a[r + 1] - a[r]) * s : -(a[r + 1] - a[r]) * tt); now = (a[r + 1] > a[r] + x ? -(a[r + 1] - x - a[r]) * s : -(a[r + 1] - a[r] - x) * tt); upd(0, 1, 0, a.size(), r + 1, a.size(), now - old); } upd(0, 0, 0, a.size(), l, r + 1, x); cout << get(0, 1, 0, a.size(), n, n + 1) << '\n'; } // sp; }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:57:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
                               ~~^~~~~~~~~~
foehn_phenomena.cpp:133:2: note: in expansion of macro 'vin'
  vin(a);
  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...