CSES - Aalto Competitive Programming 2024 - wk1 - Wed - Results
Submission details
Task:Entrepreneur
Sender:aalto2024a_009
Submission time:2024-09-04 17:49:22 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#2ACCEPTED0.00 sdetails
#30.00 sdetails
#4--details
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#8--details
#90.05 sdetails
#10--details
#11--details
#12--details
#13--details
#14--details
#150.00 sdetails

Code

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define REP(i,a,b) for (int i = a; i < b; i++)


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

    int n, t;
    cin >> n >> t;
    vector<int> inputs(n);

    REP(i, 0, n) {
        cin >> inputs[i];
    }

    sort(inputs.begin(), inputs.end());
    vector<int> mach(n);
    copy(inputs.begin(), inputs.end(), mach.begin());

    int total = 0;

    int j = 0;
    int cur = mach[0];
    int time = 0;

    while(total < t) {
        
        int k = j+1;
        bool checked = true;
        while(cur <= mach[k] && total < t) {
            mach[j] += inputs[j];
            total++;
            time = mach[j];
        }
        mach[k] += inputs[k];
        time = mach[k];
        k++;
        while(checked && total < t) {
            checked = false;
            if(mach[k] <= mach[j] && total < t) {
                checked = true;
                total++;
                time = mach[k];
                mach[k] += inputs[k];
            }
            k++;
        }

    }

    cout << time << "\n";

    return 0;
}

Test details

Test 1

Verdict:

input
10 10
6 5 1 2 1 5 10 4 6 6

correct output
4

user output
2

Test 2

Verdict: ACCEPTED

input
10 10
6 6 4 3 4 9 3 2 6 10

correct output
6

user output
6

Test 3

Verdict:

input
10 10
5 4 10 7 8 4 1 8 9 2

correct output
5

user output
4

Test 4

Verdict:

input
1 1000000000
1

correct output
1000000000

user output
(empty)

Test 5

Verdict:

input
1 1000000000
1000000000

correct output
1000000000000000000

user output
(empty)

Test 6

Verdict:

input
1000 1000
271 687 392 992 11 410 702 870...

correct output
223

user output
6

Test 7

Verdict:

input
1000 1000
598 523 703 794 737 689 724 26...

correct output
282

user output
10

Test 8

Verdict:

input
200000 1000000000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
5000

user output
(empty)

Test 9

Verdict:

input
200000 1
760045594 599341056 300698860 ...

correct output
8214

user output
18524

Test 10

Verdict:

input
200000 1000000000
33941840 210038922 596070148 7...

correct output
371045814100

user output
(empty)

Test 11

Verdict:

input
25 1000000000
1000000000 1 1 1 1 1 1 1 1 1 1...

correct output
41666667

user output
(empty)

Test 12

Verdict:

input
12 1000000000
1 1 1 1 1 1 1 1 1 1 1 10000000...

correct output
90909091

user output
(empty)

Test 13

Verdict:

input
23 1000000000
1000000000 1000000000 10000000...

correct output
43478261000000000

user output
(empty)

Test 14

Verdict:

input
23 1000000000
1000000000 1000000000 10000000...

correct output
43478261000000000

user output
(empty)

Test 15

Verdict:

input
3 3
10 11 12

correct output
12

user output
22