# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33262 | 2017-10-23T07:37:16 Z | UncleGrandpa925 | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 246 ms | 5140 KB |
/*input 3 5 1 2 0 4 1 8 1 2 2 1 1 -2 2 3 5 1 2 -1 1 3 5 2 2 5 5 0 6 -1 1 1 4 1 2 8 */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> using namespace std; #define sp ' ' #define endl '\n' #define fi first #define se second #define mp make_pair #define int long long #define N 200005 #define bit(x,y) ((x>>y)&1LL) #define show(x) cout << (#x) << ": " << x << endl; #define ii pair<int,int> ostream& operator << (ostream &os, vector<int>&x) { for (int i = 0; i < x.size(); i++) os << x[i] << sp; return os; } ostream& operator << (ostream &os, pair<int, int> x) { cout << x.fi << sp << x.se << sp; return os; } ostream& operator << (ostream &os, vector<pair<int, int> >&x) { for (int i = 0; i < x.size(); i++) os << x[i] << endl; return os; } int n, q, S, T; int a[N]; class BITrangeSum { private: int tree[N]; public: void update(int i, int val) { for (; i <= N - 5; i += i & -i) tree[i] += val; return; } int get(int i) { int ret = 0; for (; i; i -= i & -i) ret += tree[i]; return ret; } int getTree(int pos) { return get(pos) - get(pos - 1); } } BIT; int acc(int p) { return a[p] + BIT.get(p); } int curans = 0; signed main() { scanf("%lld %lld %lld %lld", &n, &q, &S, &T); n++; for (int i = 1; i <= n; i++) scanf("%lld", &a[i]); for (int i = 2; i <= n; i++) { if (a[i - 1] < a[i]) curans -= S * abs(a[i] - a[i - 1]); else curans += T * abs(a[i] - a[i - 1]); } for (int i = 1; i <= q; i++) { int l, r, val; scanf("%lld %lld %lld", &l, &r, &val); l++; r++; if (l != 1) { int x = acc(l - 1); int y = acc(l); if (x < y) curans += S * abs(x - y); else curans -= T * abs(x - y); } if (r != n) { int x = acc(r); int y = acc(r + 1); if (x < y) curans += S * abs(x - y); else curans -= T * abs(x - y); } BIT.update(l, val); BIT.update(r + 1, -val); if (l != 1) { int x = acc(l - 1); int y = acc(l); if (x < y) curans -= S * abs(x - y); else curans += T * abs(x - y); } if (r != n) { int x = acc(r); int y = acc(r + 1); if (x < y) curans -= S * abs(x - y); else curans += T * abs(x - y); } printf("%lld\n", curans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5140 KB | Output is correct |
2 | Correct | 0 ms | 5140 KB | Output is correct |
3 | Correct | 0 ms | 5140 KB | Output is correct |
4 | Correct | 0 ms | 5140 KB | Output is correct |
5 | Correct | 0 ms | 5140 KB | Output is correct |
6 | Correct | 0 ms | 5140 KB | Output is correct |
7 | Correct | 0 ms | 5140 KB | Output is correct |
8 | Correct | 0 ms | 5140 KB | Output is correct |
9 | Correct | 0 ms | 5140 KB | Output is correct |
10 | Correct | 0 ms | 5140 KB | Output is correct |
11 | Correct | 0 ms | 5140 KB | Output is correct |
12 | Correct | 0 ms | 5140 KB | Output is correct |
13 | Correct | 0 ms | 5140 KB | Output is correct |
14 | Correct | 0 ms | 5140 KB | Output is correct |
15 | Correct | 0 ms | 5140 KB | Output is correct |
16 | Correct | 3 ms | 5140 KB | Output is correct |
17 | Correct | 0 ms | 5140 KB | Output is correct |
18 | Correct | 3 ms | 5140 KB | Output is correct |
19 | Correct | 0 ms | 5140 KB | Output is correct |
20 | Correct | 0 ms | 5140 KB | Output is correct |
21 | Correct | 0 ms | 5140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 246 ms | 5140 KB | Output is correct |
2 | Correct | 239 ms | 5140 KB | Output is correct |
3 | Incorrect | 223 ms | 5140 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5140 KB | Output is correct |
2 | Correct | 0 ms | 5140 KB | Output is correct |
3 | Correct | 0 ms | 5140 KB | Output is correct |
4 | Correct | 0 ms | 5140 KB | Output is correct |
5 | Correct | 0 ms | 5140 KB | Output is correct |
6 | Correct | 0 ms | 5140 KB | Output is correct |
7 | Correct | 0 ms | 5140 KB | Output is correct |
8 | Correct | 0 ms | 5140 KB | Output is correct |
9 | Correct | 0 ms | 5140 KB | Output is correct |
10 | Correct | 0 ms | 5140 KB | Output is correct |
11 | Correct | 0 ms | 5140 KB | Output is correct |
12 | Correct | 0 ms | 5140 KB | Output is correct |
13 | Correct | 0 ms | 5140 KB | Output is correct |
14 | Correct | 0 ms | 5140 KB | Output is correct |
15 | Correct | 0 ms | 5140 KB | Output is correct |
16 | Correct | 3 ms | 5140 KB | Output is correct |
17 | Correct | 0 ms | 5140 KB | Output is correct |
18 | Correct | 3 ms | 5140 KB | Output is correct |
19 | Correct | 0 ms | 5140 KB | Output is correct |
20 | Correct | 0 ms | 5140 KB | Output is correct |
21 | Correct | 0 ms | 5140 KB | Output is correct |
22 | Correct | 246 ms | 5140 KB | Output is correct |
23 | Correct | 239 ms | 5140 KB | Output is correct |
24 | Incorrect | 223 ms | 5140 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |