Task: | Box stack I |
Sender: | aalto2024c_008 |
Submission time: | 2024-09-18 17:47:01 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | TIME LIMIT EXCEEDED | -- | details |
#32 | TIME LIMIT EXCEEDED | -- | details |
#33 | TIME LIMIT EXCEEDED | -- | details |
#34 | TIME LIMIT EXCEEDED | -- | details |
#35 | TIME LIMIT EXCEEDED | -- | details |
#36 | TIME LIMIT EXCEEDED | -- | details |
#37 | TIME LIMIT EXCEEDED | -- | details |
#38 | ACCEPTED | 0.09 s | details |
#39 | TIME LIMIT EXCEEDED | -- | details |
#40 | TIME LIMIT EXCEEDED | -- | details |
#41 | TIME LIMIT EXCEEDED | -- | details |
#42 | TIME LIMIT EXCEEDED | -- | details |
#43 | TIME LIMIT EXCEEDED | -- | details |
#44 | TIME LIMIT EXCEEDED | -- | details |
#45 | TIME LIMIT EXCEEDED | -- | details |
#46 | TIME LIMIT EXCEEDED | -- | details |
#47 | TIME LIMIT EXCEEDED | -- | details |
#48 | TIME LIMIT EXCEEDED | -- | details |
#49 | TIME LIMIT EXCEEDED | -- | details |
#50 | TIME LIMIT EXCEEDED | -- | details |
#51 | TIME LIMIT EXCEEDED | -- | details |
#52 | TIME LIMIT EXCEEDED | -- | details |
#53 | TIME LIMIT EXCEEDED | -- | details |
#54 | TIME LIMIT EXCEEDED | -- | details |
#55 | TIME LIMIT EXCEEDED | -- | details |
#56 | TIME LIMIT EXCEEDED | -- | details |
#57 | TIME LIMIT EXCEEDED | -- | details |
#58 | TIME LIMIT EXCEEDED | -- | details |
#59 | TIME LIMIT EXCEEDED | -- | details |
#60 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'void check(int, int)': input/code.cpp:102:9: warning: unused variable 'lo' [-Wunused-variable] 102 | int lo=0, hi=n; | ^~ input/code.cpp:102:15: warning: unused variable 'hi' [-Wunused-variable] 102 | int lo=0, hi=n; | ^~
Code
#ifdef ONPC #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #define char unsigned char #define rep(i, a, b) for(int i=a; i< (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define eb emplace_back #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define LSOne(S) ((S) & -(S)) using namespace std; // mt19937 rnd(239); mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); typedef long long C; typedef complex<C> P; #define X real() #define Y imag() template<class T> istream& operator>> (istream& is, complex<T>& p) { T value; is >> value; p.real(value); is >> value; p.imag(value); return is; } typedef long long ll; typedef long double ld; using pi = pair<ll, ll>; using vi = vector<ll>; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; int popcnt(int x) { return __builtin_popcount(x); } int popcnt(ll x) { return __builtin_popcountll(x); } #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef DEBUG #define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define dbg(x...) #endif template<typename S, typename T = S> void chmin(S &s, T t) {s = s < t ? s : t;} template<typename S, typename T = S> void chmax(S &s, T t) {s = s > t ? s : t;} const int INF = 1e9; // 10^9 = 1B is < 2^31-1 const ll LLINF = 4e18; // 4*10^18 is < 2^63-1 const double EPS = 1e-9; const ll MOD = 1e9+7; const int N=2020; vector<array<int, 3>> arr; //arr[N]; //int w[N], c[N], h[N]; multiset<array<int, 3>> v; bool used[N]; int res=0, n; void check(int wSum, int currH) { chmax(res, currH); int lo=0, hi=n; //std::cout << "max C can take: " << wSum; //std::cout << wSum << "<="; array<int, 3> tmp={wSum, -INF, -INF}; int left=lower_bound(arr.begin(), arr.end(), tmp)-arr.begin(); for (int i = left; i < n; i++) { if(used[i]) continue; used[i]=true; check(wSum+arr[i][1], currH+arr[i][2]); used[i]=false; } //__print(*it); std::cout << std::endl; /* return; while(lo<hi) { int mid=(lo+hi+1)/2; if(arr[mid][1]<wSum) { lo=mid; } else { hi=mid-1; } } __print(arr[lo+1]); std::cout << lo << " " << n << std::endl; */ return ; } // make {c_i, w_i, h_i} int solve() { std::cin >> n; arr.resize(n); for (int i = 0; i < n; i++) { std::cin >> arr[i][1] >> arr[i][0] >> arr[i][2]; //std::cin >> w[i] >> c[i] >> h[i]; //v.insert({c[i], w[i], h[i]}); } //check(0, 0); sort(arr.begin(), arr.end(), [&](auto &a, auto &b) { if(a[0]==b[0]) { return a[1]<b[1]; } return a[0]<b[0]; }); if(false) { for (int i = 0; i < n; i++) { std::cout << arr[i][1] << " " << arr[i][0] << " " << arr[i][2] << std::endl; } std::cout << std::endl; } //__print(arr); //return 0; //std::set<int> used; //for (int i = 0; i < n; i++) unused.insert(i); for (int i = 0; i < n; i++) { used[i]=true; //used.insert(i); check(arr[i][1], arr[i][2]); used[i]=false; //used.erase(i); //v.erase(v.find({c[i], w[i], h[i]})); //check(w[i], h[i]); //v.insert({c[i], w[i], h[i]}); } std::cout << res << std::endl; return 0; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int TET = 1; //cin >> TET; for (int i = 1; i <= TET; i++) { #ifdef ONPC cout << "TEST CASE#" << i << endl; #endif if (solve()) { break; } #ifdef ONPC cout << "__________________________" << endl; #endif } #ifdef ONPC cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; #endif }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 6 7 10 |
correct output |
---|
10 |
user output |
---|
10 |
Test 2
Verdict: ACCEPTED
input |
---|
2 5 2 4 1 2 10 |
correct output |
---|
14 |
user output |
---|
14 |
Test 3
Verdict: ACCEPTED
input |
---|
2 8 2 3 3 8 5 |
correct output |
---|
8 |
user output |
---|
8 |
Test 4
Verdict: ACCEPTED
input |
---|
3 7 3 6 10 8 9 3 6 2 |
correct output |
---|
15 |
user output |
---|
15 |
Test 5
Verdict: ACCEPTED
input |
---|
3 9 6 9 4 4 6 7 2 7 |
correct output |
---|
15 |
user output |
---|
15 |
Test 6
Verdict: ACCEPTED
input |
---|
3 10 7 6 3 2 8 2 1 9 |
correct output |
---|
23 |
user output |
---|
23 |
Test 7
Verdict: ACCEPTED
input |
---|
4 8 4 2 3 4 10 5 10 5 2 6 2 |
correct output |
---|
17 |
user output |
---|
17 |
Test 8
Verdict: ACCEPTED
input |
---|
4 3 6 5 1 1 10 10 9 5 4 8 6 |
correct output |
---|
26 |
user output |
---|
26 |
Test 9
Verdict: ACCEPTED
input |
---|
4 7 3 6 10 5 9 6 10 1 6 7 1 |
correct output |
---|
10 |
user output |
---|
10 |
Test 10
Verdict: ACCEPTED
input |
---|
4 8 1 6 2 7 7 9 6 2 5 2 10 |
correct output |
---|
17 |
user output |
---|
17 |
Test 11
Verdict: ACCEPTED
input |
---|
5 6 6 8 9 7 9 6 9 5 7 7 4 ... |
correct output |
---|
18 |
user output |
---|
18 |
Test 12
Verdict: ACCEPTED
input |
---|
5 5 10 8 10 1 2 4 10 2 3 1 4 ... |
correct output |
---|
18 |
user output |
---|
18 |
Test 13
Verdict: ACCEPTED
input |
---|
5 5 2 1 10 6 10 5 5 5 4 4 2 ... |
correct output |
---|
17 |
user output |
---|
17 |
Test 14
Verdict: ACCEPTED
input |
---|
5 6 1 8 9 3 2 6 6 9 5 9 1 ... |
correct output |
---|
17 |
user output |
---|
17 |
Test 15
Verdict: ACCEPTED
input |
---|
5 10 10 6 2 10 9 8 7 7 6 3 2 ... |
correct output |
---|
22 |
user output |
---|
22 |
Test 16
Verdict: ACCEPTED
input |
---|
5 3 1 9 9 3 4 10 10 5 1 7 4 ... |
correct output |
---|
19 |
user output |
---|
19 |
Test 17
Verdict: ACCEPTED
input |
---|
5 9 10 4 3 9 1 1 4 2 10 6 1 ... |
correct output |
---|
12 |
user output |
---|
12 |
Test 18
Verdict: ACCEPTED
input |
---|
5 1 3 8 4 5 10 8 5 10 4 6 3 ... |
correct output |
---|
28 |
user output |
---|
28 |
Test 19
Verdict: ACCEPTED
input |
---|
5 9 1 10 3 9 4 6 9 3 5 1 7 ... |
correct output |
---|
16 |
user output |
---|
16 |
Test 20
Verdict: ACCEPTED
input |
---|
5 1 4 6 5 5 1 2 4 2 1 3 9 ... |
correct output |
---|
18 |
user output |
---|
18 |
Test 21
Verdict: ACCEPTED
input |
---|
10 6 6 8 9 7 9 6 9 5 7 7 4 ... |
correct output |
---|
22 |
user output |
---|
22 |
Test 22
Verdict: ACCEPTED
input |
---|
10 5 10 8 10 1 2 4 10 2 3 1 4 ... |
correct output |
---|
29 |
user output |
---|
29 |
Test 23
Verdict: ACCEPTED
input |
---|
10 5 2 1 10 6 10 5 5 5 4 4 2 ... |
correct output |
---|
25 |
user output |
---|
25 |
Test 24
Verdict: ACCEPTED
input |
---|
10 6 1 8 9 3 2 6 6 9 5 9 1 ... |
correct output |
---|
19 |
user output |
---|
19 |
Test 25
Verdict: ACCEPTED
input |
---|
10 10 10 6 2 10 9 8 7 7 6 3 2 ... |
correct output |
---|
31 |
user output |
---|
31 |
Test 26
Verdict: ACCEPTED
input |
---|
10 3 1 9 9 3 4 10 10 5 1 7 4 ... |
correct output |
---|
28 |
user output |
---|
28 |
Test 27
Verdict: ACCEPTED
input |
---|
10 9 10 4 3 9 1 1 4 2 10 6 1 ... |
correct output |
---|
21 |
user output |
---|
21 |
Test 28
Verdict: ACCEPTED
input |
---|
10 1 3 8 4 5 10 8 5 10 4 6 3 ... |
correct output |
---|
28 |
user output |
---|
28 |
Test 29
Verdict: ACCEPTED
input |
---|
10 9 1 10 3 9 4 6 9 3 5 1 7 ... |
correct output |
---|
27 |
user output |
---|
27 |
Test 30
Verdict: ACCEPTED
input |
---|
10 1 4 6 5 5 1 2 4 2 1 3 9 ... |
correct output |
---|
29 |
user output |
---|
29 |
Test 31
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1098 1186 1431 1689 1206 1716 1090 1695 848 1248 1292 769 ... |
correct output |
---|
16023 |
user output |
---|
(empty) |
Test 32
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 835 1995 1441 1866 1 257 605 1999 294 473 185 794 ... |
correct output |
---|
16049 |
user output |
---|
(empty) |
Test 33
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 872 371 52 1864 1100 1896 871 970 841 642 661 309 ... |
correct output |
---|
14165 |
user output |
---|
(empty) |
Test 34
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1102 142 1417 1680 582 243 1022 1139 1786 875 1793 38 ... |
correct output |
---|
12391 |
user output |
---|
(empty) |
Test 35
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1935 1802 1095 346 1946 1712 1430 1219 1396 1196 433 283 ... |
correct output |
---|
19385 |
user output |
---|
(empty) |
Test 36
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 444 111 1742 1663 414 728 1838 1959 977 180 1224 794 ... |
correct output |
---|
15364 |
user output |
---|
(empty) |
Test 37
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1786 1895 664 419 1643 129 84 741 216 1971 1191 199 ... |
correct output |
---|
15648 |
user output |
---|
(empty) |
Test 38
Verdict: ACCEPTED
input |
---|
100 153 455 1560 638 877 1957 1447 912 1956 617 1077 528 ... |
correct output |
---|
12527 |
user output |
---|
12527 |
Test 39
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 1747 23 1938 479 1739 756 1062 1633 466 845 23 1225 ... |
correct output |
---|
12817 |
user output |
---|
(empty) |
Test 40
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 21 729 1004 999 992 16 268 633 285 27 438 1755 ... |
correct output |
---|
15927 |
user output |
---|
(empty) |
Test 41
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 1098 1186 1431 1689 1206 1716 1090 1695 848 1248 1292 769 ... |
correct output |
---|
20991 |
user output |
---|
(empty) |
Test 42
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 835 1995 1441 1866 1 257 605 1999 294 473 185 794 ... |
correct output |
---|
24785 |
user output |
---|
(empty) |
Test 43
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 872 371 52 1864 1100 1896 871 970 841 642 661 309 ... |
correct output |
---|
20005 |
user output |
---|
(empty) |
Test 44
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 1102 142 1417 1680 582 243 1022 1139 1786 875 1793 38 ... |
correct output |
---|
21655 |
user output |
---|
(empty) |
Test 45
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 1935 1802 1095 346 1946 1712 1430 1219 1396 1196 433 283 ... |
correct output |
---|
24716 |
user output |
---|
(empty) |
Test 46
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 444 111 1742 1663 414 728 1838 1959 977 180 1224 794 ... |
correct output |
---|
20753 |
user output |
---|
(empty) |
Test 47
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 1786 1895 664 419 1643 129 84 741 216 1971 1191 199 ... |
correct output |
---|
25462 |
user output |
---|
(empty) |
Test 48
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 153 455 1560 638 877 1957 1447 912 1956 617 1077 528 ... |
correct output |
---|
19588 |
user output |
---|
(empty) |
Test 49
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 1747 23 1938 479 1739 756 1062 1633 466 845 23 1225 ... |
correct output |
---|
19995 |
user output |
---|
(empty) |
Test 50
Verdict: TIME LIMIT EXCEEDED
input |
---|
200 21 729 1004 999 992 16 268 633 285 27 438 1755 ... |
correct output |
---|
26434 |
user output |
---|
(empty) |
Test 51
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1098 1186 1431 1689 1206 1716 1090 1695 848 1248 1292 769 ... |
correct output |
---|
51198 |
user output |
---|
(empty) |
Test 52
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 835 1995 1441 1866 1 257 605 1999 294 473 185 794 ... |
correct output |
---|
49723 |
user output |
---|
(empty) |
Test 53
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 872 371 52 1864 1100 1896 871 970 841 642 661 309 ... |
correct output |
---|
47760 |
user output |
---|
(empty) |
Test 54
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1102 142 1417 1680 582 243 1022 1139 1786 875 1793 38 ... |
correct output |
---|
46095 |
user output |
---|
(empty) |
Test 55
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 1935 1802 1095 346 1946 1712 1430 1219 1396 1196 433 283 ... |
correct output |
---|
55178 |
user output |
---|
(empty) |
Test 56
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 444 111 1742 1663 414 728 1838 1959 977 180 1224 794 ... |
correct output |
---|
76003 |
user output |
---|
(empty) |
Test 57
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 1786 1895 664 419 1643 129 84 741 216 1971 1191 199 ... |
correct output |
---|
69375 |
user output |
---|
(empty) |
Test 58
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 153 455 1560 638 877 1957 1447 912 1956 617 1077 528 ... |
correct output |
---|
68402 |
user output |
---|
(empty) |
Test 59
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 1747 23 1938 479 1739 756 1062 1633 466 845 23 1225 ... |
correct output |
---|
76262 |
user output |
---|
(empty) |
Test 60
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 21 729 1004 999 992 16 268 633 285 27 438 1755 ... |
correct output |
---|
81251 |
user output |
---|
(empty) |