Submission #952674

# Submission time Handle Problem Language Result Execution time Memory
952674 2024-03-24T13:18:50 Z Mohamed_Kachef06 Fuel Station (NOI20_fuelstation) C++17
0 / 100
3000 ms 27336 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;
    vector<array<int , 3>> B; 
    for (int i = 0 ; i < N ; i++){
        int x , a , b ;
        cin >> x >> a >> b;
        v.push_back({x , a , b});
        
    }
    v.push_back({D , 0 , 0}); 
    sort(v.begin() , v.end()); 
    for (int i = 0 ; i < N ; i++){
        
        B.push_back({v[i][2], v[i][1] , i}); 
    }
    sort(B.begin() , B.end());     
    int x[N+1] = {};
    for (int i = 0 ; i <= N ; i++){
        x[i] = - v[i][0]; 
    }
    int ans = 1e18;
    int id = 0; 
    for (int F = 0 ; F < N ; F++){
        while(id <= N && B[id][0] <= B[F][0]) { for (int j = B[id][2] + 1 ; j <= N ; j++) x[j] += B[id][1]; id++; }
        int mn = 0;
        for (int j = 0 ; j <= N ; j++) {mn = min(mn , x[j]); } 
        if (-mn <= B[F][0]) ans = min(ans , -mn);
    }
    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 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3103 ms 27336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -