Submission #1113792

# Submission time Handle Problem Language Result Execution time Memory
1113792 2024-11-17T13:05:54 Z Aviansh Fuel Station (NOI20_fuelstation) C++17
24 / 100
3000 ms 14536 KB
#include <bits/stdc++.h>

using namespace std;

int n,d;
bool check(array<int,3>fuels[], int f){
    int F=f;
    //cout << "attempting: " << f << "\n";
    for(int i = 1;i<n+2;i++){
      //  cout << "at station " << i << "\n";
        //cout << fuels[i][0] << " " << fuels[i][1] << " " << fuels[i][2] << "\n";
        f-=fuels[i][0]-fuels[i-1][0];
      //  cout << "current fuel: " << f << "\n";
        if(f<0){
            return 0;
        }
        if(F>fuels[i][2]){
            continue;
        }
        f+=fuels[i][1];
        //cout << "fueled from station " << i << "\n";
    }
    return 1;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n>>d;
    array<int,3> fuels[n+2];
    fuels[0][0]=0;
    fuels[0][1]=0;
    fuels[0][2]=d+5;
    fuels[n+1][0]=d;
    fuels[n+1][1]=0;
    fuels[n+1][2]=d+5;
    vector<int>bs;
    for(int i = 1;i<=n;i++){
        int a,b,x;
        cin >> x >> a >> b;
        fuels[i][0]=x;
        fuels[i][1]=a;
        fuels[i][2]=b;
        bs.push_back(b);
    }
    bs.push_back(d);
    sort(bs.begin(),bs.end());
    sort(fuels,fuels+n+2);
    int hi = d;
    for(int i : bs){
        if(check(fuels,i)){
            hi=i;
            break;
        }
    }
    int lo = 0;
    while(lo<hi){
        int mid = (lo+hi)/2;
        if(check(fuels,mid)){
            hi=mid;
        }
        else{
            lo=mid+1;
        }
    }
    cout << lo;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 236 ms 14536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 4 ms 592 KB Output is correct
5 Correct 4 ms 760 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 4 ms 592 KB Output is correct
15 Correct 4 ms 592 KB Output is correct
16 Correct 7 ms 592 KB Output is correct
17 Correct 4 ms 592 KB Output is correct
18 Correct 5 ms 592 KB Output is correct
19 Correct 5 ms 592 KB Output is correct
20 Correct 4 ms 848 KB Output is correct
21 Correct 4 ms 880 KB Output is correct
22 Correct 4 ms 592 KB Output is correct
23 Correct 4 ms 592 KB Output is correct
24 Correct 4 ms 592 KB Output is correct
25 Correct 4 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 4 ms 592 KB Output is correct
5 Correct 4 ms 760 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 4 ms 592 KB Output is correct
15 Correct 4 ms 592 KB Output is correct
16 Correct 7 ms 592 KB Output is correct
17 Correct 4 ms 592 KB Output is correct
18 Correct 5 ms 592 KB Output is correct
19 Correct 5 ms 592 KB Output is correct
20 Correct 4 ms 848 KB Output is correct
21 Correct 4 ms 880 KB Output is correct
22 Correct 4 ms 592 KB Output is correct
23 Correct 4 ms 592 KB Output is correct
24 Correct 4 ms 592 KB Output is correct
25 Correct 4 ms 696 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 102 ms 11140 KB Output is correct
28 Correct 95 ms 10840 KB Output is correct
29 Correct 97 ms 10444 KB Output is correct
30 Correct 94 ms 10444 KB Output is correct
31 Correct 101 ms 10948 KB Output is correct
32 Correct 96 ms 10692 KB Output is correct
33 Correct 1 ms 504 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 101 ms 10912 KB Output is correct
40 Correct 98 ms 10948 KB Output is correct
41 Correct 104 ms 10948 KB Output is correct
42 Correct 101 ms 10944 KB Output is correct
43 Correct 100 ms 10960 KB Output is correct
44 Execution timed out 3058 ms 10456 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Incorrect 1 ms 336 KB Output isn't correct
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 4 ms 640 KB Output is correct
18 Correct 4 ms 592 KB Output is correct
19 Correct 4 ms 592 KB Output is correct
20 Correct 4 ms 760 KB Output is correct
21 Correct 3 ms 592 KB Output is correct
22 Correct 4 ms 592 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 4 ms 592 KB Output is correct
30 Correct 4 ms 592 KB Output is correct
31 Correct 7 ms 592 KB Output is correct
32 Correct 4 ms 592 KB Output is correct
33 Correct 5 ms 592 KB Output is correct
34 Correct 5 ms 592 KB Output is correct
35 Correct 4 ms 848 KB Output is correct
36 Correct 4 ms 880 KB Output is correct
37 Correct 4 ms 592 KB Output is correct
38 Correct 4 ms 592 KB Output is correct
39 Correct 4 ms 592 KB Output is correct
40 Correct 4 ms 696 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Incorrect 33 ms 908 KB Output isn't correct
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Incorrect 236 ms 14536 KB Output isn't correct
17 Halted 0 ms 0 KB -