結果
問題 | No.1014 competitive fighting |
ユーザー | ミドリムシ |
提出日時 | 2020-03-20 22:57:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,949 bytes |
コンパイル時間 | 2,005 ms |
コンパイル使用メモリ | 183,760 KB |
実行使用メモリ | 12,032 KB |
最終ジャッジ日時 | 2024-05-08 23:50:33 |
合計ジャッジ時間 | 12,463 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 276 ms
11,648 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 18 ms
5,376 KB |
testcase_34 | AC | 202 ms
10,624 KB |
testcase_35 | WA | - |
testcase_36 | AC | 178 ms
10,240 KB |
testcase_37 | AC | 9 ms
5,376 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 162 ms
7,808 KB |
testcase_41 | AC | 112 ms
7,040 KB |
testcase_42 | AC | 253 ms
11,392 KB |
testcase_43 | AC | 15 ms
5,376 KB |
testcase_44 | AC | 227 ms
11,008 KB |
testcase_45 | WA | - |
testcase_46 | AC | 25 ms
5,376 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 10 ms
5,376 KB |
testcase_50 | AC | 240 ms
11,264 KB |
testcase_51 | AC | 140 ms
7,552 KB |
testcase_52 | AC | 10 ms
5,376 KB |
testcase_53 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; using lint128 = __int128_t; const lint mod = 1e9 + 7; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void assert_NO(T condition){ if(!condition){ cout << "NO" << endl; exit(0); } } template<class T> inline void assert_No(T condition){ if(!condition){ cout << "No" << endl; exit(0); } } template<class T> inline void assert_minus_1(T condition){ if(!condition){ cout << -1 << endl; exit(0); } } lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }} struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); } template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; } template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; } template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } } template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }} template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); } template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; } struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } }; template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; } template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b){ if(b < a){ a = b; return 1; } return 0; } inline int at(lint x, int k){ return (x >> k) & 1; } random_device rnd; #define rep(i, n) for(int i = 0; i < n; i++) template< typename Monoid > struct SegmentTree { using F = function< Monoid(Monoid, Monoid) >; int sz; vector< Monoid > seg; const F f; const Monoid M1; SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) { sz = 1; while(sz < n) sz <<= 1; seg.assign(2 * sz, M1); } void set(int k, const Monoid &x) { seg[k + sz] = x; } void build() { for(int k = sz - 1; k > 0; k--) { seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]); } } void update(int k, const Monoid &x) { k += sz; seg[k] = x; while(k >>= 1) { seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]); } } Monoid query(int a, int b) { Monoid L = M1, R = M1; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) L = f(L, seg[a++]); if(b & 1) R = f(seg[--b], R); } return f(L, R); } Monoid operator[](const int &k) const { return seg[k + sz]; } template< typename C > int find_subtree(int a, const C &check, Monoid &M, bool type) { while(a < sz) { Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]); if(check(nxt)) a = 2 * a + type; else M = nxt, a = 2 * a + 1 - type; } return a - sz; } template< typename C > int find_first(int a, const C &check) { Monoid L = M1; if(a <= 0) { if(check(f(L, seg[1]))) return find_subtree(1, check, L, false); return -1; } int b = sz; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) { Monoid nxt = f(L, seg[a]); if(check(nxt)) return find_subtree(a, check, L, false); L = nxt; ++a; } } return -1; } template< typename C > int find_last(int b, const C &check) { Monoid R = M1; if(b >= sz) { if(check(f(seg[1], R))) return find_subtree(1, check, R, true); return -1; } int a = sz; for(b += sz; a < b; a >>= 1, b >>= 1) { if(b & 1) { Monoid nxt = f(seg[--b], R); if(check(nxt)) return find_subtree(b, check, R, true); R = nxt; } } return -1; } }; int main(){ int N; cin >> N; tuple<lint, lint, lint, int> skill[N]; rep(i, N){ lint A, B, C; cin >> A >> B >> C; skill[i] = {A, B - C, B, i}; } sort(skill, skill + N); SegmentTree<lint> seg(N, [](lint a, lint b) { return max(a, b); }, LONG_LONG_MIN); rep(i, N){ seg.set(i, get<1>(skill[i])); } seg.build(); int right[N]; bool is_ban[N]; memset(is_ban, 0, sizeof(is_ban)); rep(i, N){ auto t = tuple<lint, lint, lint, int>(get<1>(skill[i]), LONG_LONG_MAX, 0, 0); right[i] = int(upper_bound(skill, skill + N, t) - skill); lint P_max; if(i < right[i]){ P_max = max(seg.query(0, i), seg.query(i + 1, right[i])); }else{ P_max = seg.query(0, right[i]); } is_ban[i] = (get<0>(skill[i]) <= P_max); } const lint INF = 1e18; SegmentTree<lint> power(N, [](lint a, lint b) { return max(a, b); }, 0); rep(i, N){ if(is_ban[i]){ power.set(i, INF); } } power.build(); lint ans[N]; rep(i, N){ if(!is_ban[i]){ lint this_power = power.query(0, right[i]); if(this_power != INF){ this_power += get<2>(skill[i]); } ans[get<3>(skill[i])] = this_power; power.update(i, this_power); } } rep(i, N){ if(ans[i] == INF){ cout << "BAN" << endl; }else{ cout << ans[i] << endl; } } }