Submission details
Task:Roller coaster
Sender:aalto26hw_006
Submission time:2026-10-28 17:48:33 +0200
Language:C++ (C++23)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

// debug
template<class T> ostream& operator<<(ostream&, const vector<T>&);
template<class T> ostream& operator<<(ostream&, const set<T>&);
template<class T> ostream& operator<<(ostream&, const multiset<T>&);
template<class K, class V> ostream& operator<<(ostream&, const map<K, V>&);
template<class T, size_t N> ostream& operator<<(ostream&, const array<T, N>&);
template<class A, class B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template<class T>
void print_collection(ostream& os, const T& v) {
    os << "{";
    bool first = true;
    for (const auto& x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << "}";
}
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { print_collection(os, v); return os; }
template<class T> ostream& operator<<(ostream& os, const set<T>& v) { print_collection(os, v); return os; }
template<class T> ostream& operator<<(ostream& os, const multiset<T>& v) { print_collection(os, v); return os; }
template<class K, class V> ostream& operator<<(ostream& os, const map<K, V>& v) { print_collection(os, v); return os; }
template<class T, size_t N> ostream& operator<<(ostream& os, const array<T, N>& v) { print_collection(os, v); return os; }
#define dbg(x) cerr << #x << " = " << (x) << '\n'

using ll = long long;
constexpr int INF = 1'000'000'000; // 1e9
constexpr ll LINF = 1'000'000'000'000'000'000LL; // 1e18
constexpr int MOD = 1'000'000'007; // 1e9 + 7

inline ll add(ll a, ll b) { return (a + b) % MOD; }
inline ll sub(ll a, ll b) { return ((a - b) % MOD + MOD) % MOD; }
inline ll mul(ll a, ll b) { return (a * b) % MOD; }

#define P(i) get<0>(x[i])
#define R(i) get<1>(x[i])
#define A(i) get<2>(x[i])
#define F(i) get<3>(x[i])


void solve() {
    int N;
    cin >> N;

    // P (happy), R (min), A (total red), F (frac red)
    vector<tuple<double, double, int, int>> x(N);
    for(int i=0;i<N;++i) {
        cin >> get<0>(x[i]) >> get<1>(x[i]) >> get<2>(x[i]) >> get<3>(x[i]);
    }
    
    double min = INF;

    for(int i = 0; i < 1<<(N+1); i++) {
        if(__builtin_popcount(i)>(N+1)/2) continue;
        int p = 0;
        double currentR = R(N-1);
        if((i & (1<<N)) > 0) currentR = P(N-1);
        if(currentR >= P(N-1)) p++;
        for(int j = N-2; j>=0; j--) {
            currentR = max(R(j), (100 * (currentR + A(j))) / (100-F(j)));
            if((i & (1 << j)) > 0) currentR = max(P(j), currentR);
            if(currentR >= P(j)) p++;
        }
        if(p>=(N+1)/2 && currentR < min) min = currentR;
    }

    cout << min << endl;
    cout << ceil(min);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();

    return 0;
}

Test details

Test 1

Verdict:

input
3
1000 5 5 0
20 20 20 50
50 50 0 99

correct output
145

user output
145
145

Feedback: Output is longer than expected

Test 2

Verdict:

input
10
1000000 1000000 1000000 99
1000000 1000000 1000000 99
1000000 1000000 1000000 99
1000000 1000000 1000000 99
...

correct output
2010101010101010100000000

user output
1e+09
1e+09

Feedback: Output is longer than expected

Test 3

Verdict:

input
7
794772 933488 441001 5
271493 536110 509532 51
962838 821872 870163 38
499748 375441 611720 27
...

correct output
19316405

user output
1.93164e+07
1.93164e+07

Feedback: Output is longer than expected

Test 4

Verdict:

input
3
596853 888598 841235 97
66172 267459 123646 63
797926 471325 495185 83

correct output
81642158

user output
8.16422e+07
8.16422e+07

Feedback: Output is longer than expected

Test 5

Verdict:

input
1
96033 88994 378596 21

correct output
96033

user output
96033
96033

Feedback: Output is longer than expected

Test 6

Verdict:

input
4
621429 570665 136758 47
960437 633256 497081 80
609067 68711 635017 1
952965 878149 492025 33

correct output
19366822

user output
1.93668e+07
1.93668e+07

Feedback: Output is longer than expected

Test 7

Verdict:

input
4
318031 108177 756250 50
502140 162500 94476 8
20779 421098 576089 37
839335 802331 61705 28

correct output
6474336

user output
6.47434e+06
6.47434e+06

Feedback: Output is longer than expected

Test 8

Verdict:

input
10
267853 777820 375951 88
988230 882388 775839 83
967127 555787 30414 59
813651 989181 261150 83
...

correct output
114240784216

user output
1e+09
1e+09

Feedback: Output is longer than expected

Test 9

Verdict:

input
10
861881 84483 508595 97
274330 38611 473 18
695015 614973 493097 97
770531 391287 334900 98
...

correct output
26667465547194

user output
1e+09
1e+09

Feedback: Output is longer than expected

Test 10

Verdict:

input
6
993908 158176 414002 83
50631 75954 861168 68
98702 383452 611097 7
953893 532084 225127 4
...

correct output
46921821

user output
4.69218e+07
4.69218e+07

Feedback: Output is longer than expected

Test 11

Verdict:

input
4
388404 393603 132467 24
739054 45905 89323 17
259460 850672 530957 26
420175 673047 31765 58

correct output
2895218

user output
2.35349e+06
2.3535e+06

Feedback: Output is longer than expected

Test 12

Verdict:

input
8
643002 391445 280110 17
195187 908655 709512 0
354760 527205 486247 77
84740 350249 581194 78
...

correct output
250399569

user output
2.40687e+08
2.40687e+08

Feedback: Output is longer than expected