Submission #952689

# Submission time Handle Problem Language Result Execution time Memory
952689 2024-03-24T14:42:32 Z Mohamed_Kachef06 Fuel Station (NOI20_fuelstation) C++17
54 / 100
3000 ms 30420 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long 



void doWork(){
    int n , d;
    cin >> n >> d;
    vector<array<int , 3>> v(n+1); 
    vector<array<int , 3>> u(n); 
    int arr[n+1] = {};
    // arr[i] = cost to go from i to i+1

    for (int i=  1 ; i <= n ; i++){
        for (int j = 0 ; j < 3 ; j++){
            cin >> v[i][j]; 
        }
    }
    v.push_back({d , 0 , 0});
    sort(v.begin() , v.end());

    for (int i = 1 ; i <= n ; i++){
        u[i-1] = {v[i][2] , v[i][1] , i}; 
    }
    u.push_back({(int)1e18 , 0 , 0});
    sort(u.begin() , u.end() , greater<>());

    for (int i = 0 ; i <= n ; i++){
        arr[i] = v[i+1][0] - v[i][0]; 
    }
    
    int ans = 1e18;
    int id = 0;
    for (int i = 0 ; i <= n ; i++){
        while (id <= n && u[id][0] >= u[i][0]) { arr[u[id][2]]-=u[id][1]; id++;}
        int mx = 0 , sum = 0;
        for (int j = 0 ; j <= n ; j++) {
            //cout << arr[j] << ' ' ;
            sum += arr[j]; 
            mx = max(mx , sum);
        }
        // cout << mx << ' ' << u[i][0] << '\n';
        // cout << '\n';
        if (mx <= u[i][0]) ans = min(ans , mx);
    }
    cout << ans; 
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    doWork(); 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3087 ms 30420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 96 ms 1372 KB Output is correct
3 Correct 96 ms 1388 KB Output is correct
4 Correct 96 ms 1372 KB Output is correct
5 Correct 96 ms 1368 KB Output is correct
6 Correct 95 ms 1372 KB Output is correct
7 Correct 96 ms 1388 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 96 ms 1392 KB Output is correct
15 Correct 96 ms 1392 KB Output is correct
16 Correct 96 ms 1392 KB Output is correct
17 Correct 100 ms 1392 KB Output is correct
18 Correct 96 ms 1368 KB Output is correct
19 Correct 96 ms 1368 KB Output is correct
20 Correct 98 ms 1392 KB Output is correct
21 Correct 104 ms 1400 KB Output is correct
22 Correct 96 ms 1372 KB Output is correct
23 Correct 96 ms 1368 KB Output is correct
24 Correct 97 ms 1392 KB Output is correct
25 Correct 96 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 96 ms 1372 KB Output is correct
3 Correct 96 ms 1388 KB Output is correct
4 Correct 96 ms 1372 KB Output is correct
5 Correct 96 ms 1368 KB Output is correct
6 Correct 95 ms 1372 KB Output is correct
7 Correct 96 ms 1388 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 96 ms 1392 KB Output is correct
15 Correct 96 ms 1392 KB Output is correct
16 Correct 96 ms 1392 KB Output is correct
17 Correct 100 ms 1392 KB Output is correct
18 Correct 96 ms 1368 KB Output is correct
19 Correct 96 ms 1368 KB Output is correct
20 Correct 98 ms 1392 KB Output is correct
21 Correct 104 ms 1400 KB Output is correct
22 Correct 96 ms 1372 KB Output is correct
23 Correct 96 ms 1368 KB Output is correct
24 Correct 97 ms 1392 KB Output is correct
25 Correct 96 ms 1372 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Execution timed out 3071 ms 27648 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 96 ms 1372 KB Output is correct
18 Correct 96 ms 1388 KB Output is correct
19 Correct 96 ms 1372 KB Output is correct
20 Correct 96 ms 1368 KB Output is correct
21 Correct 95 ms 1372 KB Output is correct
22 Correct 96 ms 1388 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 96 ms 1392 KB Output is correct
30 Correct 96 ms 1392 KB Output is correct
31 Correct 96 ms 1392 KB Output is correct
32 Correct 100 ms 1392 KB Output is correct
33 Correct 96 ms 1368 KB Output is correct
34 Correct 96 ms 1368 KB Output is correct
35 Correct 98 ms 1392 KB Output is correct
36 Correct 104 ms 1400 KB Output is correct
37 Correct 96 ms 1372 KB Output is correct
38 Correct 96 ms 1368 KB Output is correct
39 Correct 97 ms 1392 KB Output is correct
40 Correct 96 ms 1372 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 97 ms 1392 KB Output is correct
43 Correct 96 ms 1388 KB Output is correct
44 Correct 97 ms 1388 KB Output is correct
45 Correct 96 ms 1392 KB Output is correct
46 Correct 96 ms 1392 KB Output is correct
47 Correct 97 ms 1392 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 97 ms 1392 KB Output is correct
55 Correct 97 ms 1392 KB Output is correct
56 Correct 97 ms 1392 KB Output is correct
57 Correct 96 ms 1388 KB Output is correct
58 Correct 96 ms 1388 KB Output is correct
59 Correct 96 ms 1392 KB Output is correct
60 Correct 97 ms 1388 KB Output is correct
61 Correct 102 ms 1396 KB Output is correct
62 Correct 97 ms 1392 KB Output is correct
63 Correct 97 ms 1392 KB Output is correct
64 Correct 97 ms 1404 KB Output is correct
65 Correct 102 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Execution timed out 3087 ms 30420 KB Time limit exceeded
17 Halted 0 ms 0 KB -