Submission #951871

# Submission time Handle Problem Language Result Execution time Memory
951871 2024-03-22T21:20:49 Z Mohamed_Kachef06 Fuel Station (NOI20_fuelstation) C++17
0 / 100
3000 ms 18556 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<int> B(1 , 1e18); 
    for (int i = 1 ; i <= n ; i++){
        int x , a , b;
        cin >> x >> a >> b;
        v.push_back({x , a , b});
        B.push_back(b); 
    }
    sort(v.begin() , v.end()); 
    sort(B.begin() , B.end()); 
    int x[n+2] = {} , a[n+2] = {} , b[n+2] = {};
    for (int i = 1 ; i <= n ; i++){
        x[i] = v[i-1][0];
        a[i] = v[i-1][1];
        b[i] = v[i-1][2]; 
    }
    x[n+1] = d; 
    int ans = 1e18;
    for (int i = 0 ; i <= n ; i++){
       // cout << B[i] << '\n' << '\n';
        int mn = 0 , sum = 0 , temp = 0;
        for (int j = 1 ; j <= n+1 ; j++){
         if (x[j] != x[j-1]) { sum += temp; temp = 0; }
             //       cout << x[j] << ' ' << sum << '\n';
           mn = min(mn , -x[j] + sum);
           if (b[j] <= B[i]) temp += a[j]; 
        }
        //cout << '\n';
        //cout << '\n';
        if (-mn <= B[i]) 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 3041 ms 18556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 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 -