Submission #546983

# Submission time Handle Problem Language Result Execution time Memory
546983 2022-04-09T05:28:26 Z socpite Fuel Station (NOI20_fuelstation) C++14
67 / 100
3000 ms 5504 KB
#include<bits/stdc++.h>
using namespace std;

#define f first
#define s second

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

const int maxn = 3e5+5;

int n, D;
int ans, crr;
pair<int, pii> fuel[maxn];
int sB[maxn];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> D;
    fuel[0].f = 0;
    for(int i = 1; i <= n; i++){
        cin >> fuel[i].f >> fuel[i].s.f >> fuel[i].s.s;
        sB[i] = fuel[i].s.s;
    }
    sort(sB+1, sB+n+1);
    sort(fuel+1, fuel+n+1);
    for(int i = 1; i <= n; i++){
        ll crr = 0, ff = 0, gg = 1;
        for(int j = 1; j <= n; j++){
            crr-=fuel[j].f-fuel[j-1].f;
            if(crr < 0){
                ff-=crr;
                crr = 0;
            }
            if(fuel[j].s.s >= sB[i])crr+=fuel[j].s.f;
            if(ff > sB[i]){
                gg = 0;
                break;
            }
        }
        crr -= D-fuel[n].f;
        if(crr < 0){
            ff-=crr;
            crr = 0;
        }
        if(ff > sB[i])gg=0;
        if(gg){
            cout << ff;
            return 0;
        }
    }
    cout << D;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 125 ms 5004 KB Output is correct
2 Correct 126 ms 5196 KB Output is correct
3 Correct 127 ms 5172 KB Output is correct
4 Correct 133 ms 5196 KB Output is correct
5 Correct 128 ms 5208 KB Output is correct
6 Correct 127 ms 5384 KB Output is correct
7 Correct 127 ms 5400 KB Output is correct
8 Correct 127 ms 5224 KB Output is correct
9 Correct 127 ms 5264 KB Output is correct
10 Correct 125 ms 5316 KB Output is correct
11 Correct 129 ms 5384 KB Output is correct
12 Correct 127 ms 5204 KB Output is correct
13 Correct 127 ms 5504 KB Output is correct
14 Correct 125 ms 5204 KB Output is correct
15 Correct 123 ms 5256 KB Output is correct
16 Correct 126 ms 5284 KB Output is correct
17 Correct 140 ms 5260 KB Output is correct
18 Correct 123 ms 5224 KB Output is correct
19 Correct 127 ms 5280 KB Output is correct
20 Correct 129 ms 5268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 4 ms 468 KB Output is correct
7 Correct 4 ms 468 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 5 ms 476 KB Output is correct
16 Correct 4 ms 468 KB Output is correct
17 Correct 4 ms 468 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 6 ms 468 KB Output is correct
20 Correct 4 ms 468 KB Output is correct
21 Correct 4 ms 468 KB Output is correct
22 Correct 4 ms 468 KB Output is correct
23 Correct 4 ms 468 KB Output is correct
24 Correct 4 ms 468 KB Output is correct
25 Correct 5 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 4 ms 468 KB Output is correct
7 Correct 4 ms 468 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 5 ms 476 KB Output is correct
16 Correct 4 ms 468 KB Output is correct
17 Correct 4 ms 468 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 6 ms 468 KB Output is correct
20 Correct 4 ms 468 KB Output is correct
21 Correct 4 ms 468 KB Output is correct
22 Correct 4 ms 468 KB Output is correct
23 Correct 4 ms 468 KB Output is correct
24 Correct 4 ms 468 KB Output is correct
25 Correct 5 ms 468 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 107 ms 4996 KB Output is correct
28 Correct 107 ms 5000 KB Output is correct
29 Correct 117 ms 4996 KB Output is correct
30 Correct 108 ms 4896 KB Output is correct
31 Correct 124 ms 4940 KB Output is correct
32 Correct 108 ms 4928 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 117 ms 4944 KB Output is correct
40 Correct 109 ms 5000 KB Output is correct
41 Correct 112 ms 4996 KB Output is correct
42 Correct 109 ms 4968 KB Output is correct
43 Correct 110 ms 4876 KB Output is correct
44 Execution timed out 3056 ms 4936 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 4 ms 468 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
20 Correct 4 ms 468 KB Output is correct
21 Correct 4 ms 468 KB Output is correct
22 Correct 4 ms 468 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 5 ms 476 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 4 ms 468 KB Output is correct
34 Correct 6 ms 468 KB Output is correct
35 Correct 4 ms 468 KB Output is correct
36 Correct 4 ms 468 KB Output is correct
37 Correct 4 ms 468 KB Output is correct
38 Correct 4 ms 468 KB Output is correct
39 Correct 4 ms 468 KB Output is correct
40 Correct 5 ms 468 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 7 ms 468 KB Output is correct
43 Correct 5 ms 724 KB Output is correct
44 Correct 5 ms 680 KB Output is correct
45 Correct 5 ms 724 KB Output is correct
46 Correct 6 ms 724 KB Output is correct
47 Correct 5 ms 680 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 5 ms 680 KB Output is correct
55 Correct 7 ms 724 KB Output is correct
56 Correct 6 ms 724 KB Output is correct
57 Correct 5 ms 724 KB Output is correct
58 Correct 6 ms 772 KB Output is correct
59 Correct 5 ms 724 KB Output is correct
60 Correct 4 ms 800 KB Output is correct
61 Correct 5 ms 724 KB Output is correct
62 Correct 7 ms 724 KB Output is correct
63 Correct 5 ms 724 KB Output is correct
64 Correct 5 ms 724 KB Output is correct
65 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 125 ms 5004 KB Output is correct
17 Correct 126 ms 5196 KB Output is correct
18 Correct 127 ms 5172 KB Output is correct
19 Correct 133 ms 5196 KB Output is correct
20 Correct 128 ms 5208 KB Output is correct
21 Correct 127 ms 5384 KB Output is correct
22 Correct 127 ms 5400 KB Output is correct
23 Correct 127 ms 5224 KB Output is correct
24 Correct 127 ms 5264 KB Output is correct
25 Correct 125 ms 5316 KB Output is correct
26 Correct 129 ms 5384 KB Output is correct
27 Correct 127 ms 5204 KB Output is correct
28 Correct 127 ms 5504 KB Output is correct
29 Correct 125 ms 5204 KB Output is correct
30 Correct 123 ms 5256 KB Output is correct
31 Correct 126 ms 5284 KB Output is correct
32 Correct 140 ms 5260 KB Output is correct
33 Correct 123 ms 5224 KB Output is correct
34 Correct 127 ms 5280 KB Output is correct
35 Correct 129 ms 5268 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 4 ms 468 KB Output is correct
38 Correct 4 ms 468 KB Output is correct
39 Correct 4 ms 468 KB Output is correct
40 Correct 4 ms 468 KB Output is correct
41 Correct 4 ms 468 KB Output is correct
42 Correct 4 ms 468 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 4 ms 468 KB Output is correct
50 Correct 5 ms 476 KB Output is correct
51 Correct 4 ms 468 KB Output is correct
52 Correct 4 ms 468 KB Output is correct
53 Correct 4 ms 468 KB Output is correct
54 Correct 6 ms 468 KB Output is correct
55 Correct 4 ms 468 KB Output is correct
56 Correct 4 ms 468 KB Output is correct
57 Correct 4 ms 468 KB Output is correct
58 Correct 4 ms 468 KB Output is correct
59 Correct 4 ms 468 KB Output is correct
60 Correct 5 ms 468 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 107 ms 4996 KB Output is correct
63 Correct 107 ms 5000 KB Output is correct
64 Correct 117 ms 4996 KB Output is correct
65 Correct 108 ms 4896 KB Output is correct
66 Correct 124 ms 4940 KB Output is correct
67 Correct 108 ms 4928 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 0 ms 212 KB Output is correct
73 Correct 0 ms 212 KB Output is correct
74 Correct 117 ms 4944 KB Output is correct
75 Correct 109 ms 5000 KB Output is correct
76 Correct 112 ms 4996 KB Output is correct
77 Correct 109 ms 4968 KB Output is correct
78 Correct 110 ms 4876 KB Output is correct
79 Execution timed out 3056 ms 4936 KB Time limit exceeded
80 Halted 0 ms 0 KB -