結果
問題 | No.2957 Combo Deck Builder |
ユーザー | sibasyun |
提出日時 | 2024-11-21 22:36:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,403 bytes |
コンパイル時間 | 6,411 ms |
コンパイル使用メモリ | 296,028 KB |
実行使用メモリ | 14,912 KB |
最終ジャッジ日時 | 2024-11-21 22:36:38 |
合計ジャッジ時間 | 20,235 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 3 ms
6,816 KB |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 3 ms
6,816 KB |
testcase_06 | AC | 362 ms
11,552 KB |
testcase_07 | AC | 351 ms
11,688 KB |
testcase_08 | AC | 331 ms
11,756 KB |
testcase_09 | AC | 315 ms
11,652 KB |
testcase_10 | AC | 312 ms
11,564 KB |
testcase_11 | AC | 340 ms
11,756 KB |
testcase_12 | AC | 307 ms
11,580 KB |
testcase_13 | AC | 318 ms
11,756 KB |
testcase_14 | AC | 293 ms
11,584 KB |
testcase_15 | AC | 314 ms
11,648 KB |
testcase_16 | AC | 289 ms
11,664 KB |
testcase_17 | AC | 293 ms
11,692 KB |
testcase_18 | AC | 285 ms
11,752 KB |
testcase_19 | AC | 321 ms
11,840 KB |
testcase_20 | AC | 311 ms
11,616 KB |
testcase_21 | AC | 300 ms
11,648 KB |
testcase_22 | AC | 313 ms
11,756 KB |
testcase_23 | AC | 310 ms
11,776 KB |
testcase_24 | AC | 289 ms
11,568 KB |
testcase_25 | AC | 290 ms
11,644 KB |
testcase_26 | AC | 281 ms
14,700 KB |
testcase_27 | AC | 343 ms
14,912 KB |
testcase_28 | AC | 283 ms
14,256 KB |
testcase_29 | AC | 310 ms
14,532 KB |
testcase_30 | AC | 237 ms
14,320 KB |
testcase_31 | AC | 260 ms
14,052 KB |
testcase_32 | AC | 236 ms
13,984 KB |
testcase_33 | AC | 266 ms
14,756 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 2 ms
6,820 KB |
testcase_37 | AC | 2 ms
6,816 KB |
testcase_38 | AC | 3 ms
6,816 KB |
testcase_39 | AC | 2 ms
6,820 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> #include <algorithm> #include <iostream> #include <iomanip> #include <math.h> #include <random> #include <chrono> #include <cstdint> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace atcoder; using namespace __gnu_pbds; using mint = modint998244353; // using mint = modint1000000007; using vi = vector<int>; using vvi = vector<vector<int>>; using vvvi = vector<vector<vector<int>>>; using vl = vector<long long>; using vvl = vector<vector<long long>>; using vvvl = vector<vector<vector<long long>>>; using vm = vector<mint>; using vvm = vector<vector<mint>>; using vvvm = vector<vector<vector<mint>>>; using ll = long long; using pd_ds_set_int = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; using pd_ds_set_ll = tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update>; template <class T> using max_heap = priority_queue<T>; template <class T> using min_heap = priority_queue<T, vector<T>, greater<>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, f, n) for (int i = (int) f; i < (int)(n); i++) #define repd(i, n, l) for (int i = (int) n; i >= (int) l; i--) #define all(p) p.begin(),p.end() vector<pair<int, int>> dydx{{-1, 0}, {1, 0}, {0, -1 }, {0, 1}}; const ll inf = 1LL << 60; void print(){ putchar(' '); } void print(bool a){ printf("%d", a); } void print(int a){ printf("%d", a); } void print(unsigned a){ printf("%u", a); } void print(long a){ printf("%ld", a); } void print(long long a){ printf("%lld", a); } void print(unsigned long long a){ printf("%llu", a); } void print(char a){ printf("%c", a); } void print(char a[]){ printf("%s", a); } void print(const char a[]){ printf("%s", a); } void print(float a){ printf("%.15f", a); } void print(double a){ printf("%.15f", a); } void print(long double a){ printf("%.15Lf", a); } void print(const string& a){ for(auto&& i : a) print(i); } template<class T> void print(const complex<T>& a){ if(a.real() >= 0) print('+'); print(a.real()); if(a.imag() >= 0) print('+'); print(a.imag()); print('i'); } template<class T> void print(const vector<T>&); template<class T, size_t size> void print(const array<T, size>&); template<class T, class L> void print(const pair<T, L>& p); template<class T, size_t size> void print(const T (&)[size]); template<class T> void print(const vector<T>& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ putchar(' '); print(*i); } } template<class T> void print(const deque<T>& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ putchar(' '); print(*i); } } template<class T, size_t size> void print(const array<T, size>& a){ print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ putchar(' '); print(*i); } } template<class T, class L> void print(const pair<T, L>& p){ print(p.first); putchar(' '); print(p.second); } template<class T, size_t size> void print(const T (&a)[size]){ print(a[0]); for(auto i = a; ++i != end(a); ){ putchar(' '); print(*i); } } template<class T> void print(const T& a){ cout << a; } constexpr ll ten(int n){ return n==0?1:ten(n-1)*10; } template <typename T> vector<T> compress_coordinate(vector<T> &A){ int n = A.size(); vector<T> B(n); rep(i, n) B[i] = A[i]; sort(B.begin(), B.end()); B.erase(unique(B.begin(), B.end()), B.end()); return B; } vector<vector<int>> unweighted_graph(int n, int m){ vector<vector<int>> ret(n); while (m--){ int a, b; cin >> a >> b; a--; b--; ret[a].push_back(b); ret[b].push_back(a); } return ret; } vector<vector<pair<int, long long>>> weighted_graph(int n, int m){ vector<vector<pair<int, long long>>> ret(n); while (m--){ int a, b; long long c; cin >> a >> b >> c; a--, b--; ret[a].push_back({b, c}); ret[b].push_back({a, c}); } return ret; } template<typename T> int argmin(vector<T> &a){ T mi = *min_element(all(a)); for (int i = 0; i < a.size(); i++){ if (a[i] == mi) return i; } } template<typename T> int argmax(vector<T> &a){ T ma = *max_element(all(a)); for (int i = 0; i < a.size(); i++){ if (a[i] == ma) return i; } } int main() { int N; cin >> N; vl C(N), X(N), Y(N); rep(i, N) cin >> C[i] >> X[i] >> Y[i]; vi ord(N); iota(all(ord), 0); sort(all(ord), [&](int i, int j){ return C[i] < C[j]; }); max_heap<pair<ll, int>> hq; vi used(N); ll ans = 0; int id = 0; rep2(i, 1, N+1){ while (id < N && C[ord[id]] + 1 <= i){ hq.push({X[ord[id]] - Y[ord[id]], ord[id]}); id++; } if (hq.empty()) continue; auto [a, b] = hq.top(); if (a < 0) continue; hq.pop(); ans += X[b]; used[b] = 1; } while (!hq.empty()) hq.pop(); id = N-1; for (int i = N; i > 0; i--){ while (id >= 0 && C[ord[id]] >= i){ hq.push({Y[ord[id]] - X[ord[id]], ord[id]}); id--; } if (hq.empty()) continue; auto [a, b] = hq.top(); if (a < 0) continue; hq.pop(); ans += Y[b]; used[b] = 1; } rep(i, N) if (!used[i]) ans += min(X[i], Y[i]); cout << ans << endl; return 0; }