Submission #952371

# Submission time Handle Problem Language Result Execution time Memory
952371 2024-03-23T16:07:00 Z vjudge306 Fuel Station (NOI20_fuelstation) C++17
37 / 100
3000 ms 8284 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nn "\n"
#define x_x ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define intt int _; cin >> _; while (_--)
#define emp push_back
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define ld long double
#define A first
#define B second
//#define int long long
typedef long long ll;
const ld eps = 1e-27;
// diff between decimals 0.000000001 mt19937 mt(time(nullptr));
struct in {
int a; int b; int c;
};
bool ss(in a, in b) {
return a.a<b.a;
}
int main() {

    x_x
    int n,d; cin>>n>>d; in ar[n]; int mn=INT_MAX;
    for (auto&i:ar) cin>>i.a>>i.c>>i.b, mn=min(mn,i.b);
    sort(ar, ar+n,ss);
    if (n==1) {
        int x=d; int y=max(ar[0].a, d-ar[0].c); if (y>ar[0].b) y=d;
        cout<<min(x,y);
    }
    else if(mn==(1e9)) {
        ll f=0, x=0; ll s=f;
        for (int i=0; i<n&&ar[i].a<d; i++) {
            f-=(ar[i].a-x), x=ar[i].a;
            if(f<0)s+=(f*-1),f=0;
             f+=ar[i].c;
        }
        f-=(d-x); if(f<0) s+=(f*-1);
        cout<<s;
    }
    else if(d<=10000) {
       //int ans=d;
        for (int z=1; z<=d; z++) {
    ll f=z, x=0; bool ok=1;
        for (int i=0; i<n; i++) {
            f-=(ar[i].a-x), x=ar[i].a;
            if(f<0){ok=0; break;}
            if (z<=ar[i].b) f+=ar[i].c;
        }
        if ((d-x)>f)ok=0;
        if (ok) {cout<<z; break;}
        }
    }
   /* else if(n<=10000) {
            int ans=d;
        for (int z=0; z<n; z++) {
            int mx=ar[z].b;
    ll f=0, x=0; ll s=f;
        for (int i=0; i<n&; i++) {
            f-=(ar[i].a-x), x=ar[i].a;
            if(f<0)s+=(f*-1),f=0;
             if(ar[i].b>=s)f+=ar[i].c;
        }
        }
    }*/
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 3952 KB Output is correct
2 Correct 96 ms 3932 KB Output is correct
3 Correct 93 ms 3948 KB Output is correct
4 Correct 86 ms 3948 KB Output is correct
5 Correct 92 ms 3928 KB Output is correct
6 Correct 88 ms 3932 KB Output is correct
7 Correct 90 ms 3928 KB Output is correct
8 Correct 86 ms 3928 KB Output is correct
9 Correct 93 ms 3928 KB Output is correct
10 Correct 83 ms 3928 KB Output is correct
11 Correct 89 ms 3944 KB Output is correct
12 Correct 86 ms 4184 KB Output is correct
13 Correct 89 ms 3948 KB Output is correct
14 Correct 91 ms 3932 KB Output is correct
15 Correct 91 ms 3960 KB Output is correct
16 Correct 93 ms 3952 KB Output is correct
17 Correct 87 ms 3944 KB Output is correct
18 Correct 94 ms 3932 KB Output is correct
19 Correct 87 ms 3932 KB Output is correct
20 Correct 92 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 4 ms 604 KB Output is correct
16 Correct 11 ms 716 KB Output is correct
17 Correct 21 ms 604 KB Output is correct
18 Correct 26 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 3 ms 684 KB Output is correct
25 Correct 3 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 4 ms 604 KB Output is correct
16 Correct 11 ms 716 KB Output is correct
17 Correct 21 ms 604 KB Output is correct
18 Correct 26 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 3 ms 684 KB Output is correct
25 Correct 3 ms 700 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 70 ms 8160 KB Output is correct
28 Correct 74 ms 7900 KB Output is correct
29 Correct 77 ms 7728 KB Output is correct
30 Correct 71 ms 7916 KB Output is correct
31 Correct 87 ms 8284 KB Output is correct
32 Correct 72 ms 8020 KB Output is correct
33 Correct 0 ms 600 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 68 ms 8280 KB Output is correct
40 Correct 76 ms 8152 KB Output is correct
41 Correct 100 ms 8276 KB Output is correct
42 Correct 72 ms 8276 KB Output is correct
43 Correct 652 ms 8248 KB Output is correct
44 Correct 1112 ms 7784 KB Output is correct
45 Execution timed out 3035 ms 7252 KB Time limit exceeded
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 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 Incorrect 0 ms 348 KB Output isn't correct
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 3 ms 600 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 11 ms 716 KB Output is correct
32 Correct 21 ms 604 KB Output is correct
33 Correct 26 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 3 ms 604 KB Output is correct
36 Correct 3 ms 724 KB Output is correct
37 Correct 3 ms 604 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 3 ms 684 KB Output is correct
40 Correct 3 ms 700 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Incorrect 3 ms 724 KB Output isn't correct
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 89 ms 3952 KB Output is correct
17 Correct 96 ms 3932 KB Output is correct
18 Correct 93 ms 3948 KB Output is correct
19 Correct 86 ms 3948 KB Output is correct
20 Correct 92 ms 3928 KB Output is correct
21 Correct 88 ms 3932 KB Output is correct
22 Correct 90 ms 3928 KB Output is correct
23 Correct 86 ms 3928 KB Output is correct
24 Correct 93 ms 3928 KB Output is correct
25 Correct 83 ms 3928 KB Output is correct
26 Correct 89 ms 3944 KB Output is correct
27 Correct 86 ms 4184 KB Output is correct
28 Correct 89 ms 3948 KB Output is correct
29 Correct 91 ms 3932 KB Output is correct
30 Correct 91 ms 3960 KB Output is correct
31 Correct 93 ms 3952 KB Output is correct
32 Correct 87 ms 3944 KB Output is correct
33 Correct 94 ms 3932 KB Output is correct
34 Correct 87 ms 3932 KB Output is correct
35 Correct 92 ms 3932 KB Output is correct
36 Correct 0 ms 600 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 3 ms 348 KB Output is correct
39 Correct 3 ms 344 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 3 ms 348 KB Output is correct
42 Correct 3 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 3 ms 600 KB Output is correct
50 Correct 4 ms 604 KB Output is correct
51 Correct 11 ms 716 KB Output is correct
52 Correct 21 ms 604 KB Output is correct
53 Correct 26 ms 604 KB Output is correct
54 Correct 2 ms 604 KB Output is correct
55 Correct 3 ms 604 KB Output is correct
56 Correct 3 ms 724 KB Output is correct
57 Correct 3 ms 604 KB Output is correct
58 Correct 2 ms 604 KB Output is correct
59 Correct 3 ms 684 KB Output is correct
60 Correct 3 ms 700 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 70 ms 8160 KB Output is correct
63 Correct 74 ms 7900 KB Output is correct
64 Correct 77 ms 7728 KB Output is correct
65 Correct 71 ms 7916 KB Output is correct
66 Correct 87 ms 8284 KB Output is correct
67 Correct 72 ms 8020 KB Output is correct
68 Correct 0 ms 600 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 344 KB Output is correct
73 Correct 1 ms 348 KB Output is correct
74 Correct 68 ms 8280 KB Output is correct
75 Correct 76 ms 8152 KB Output is correct
76 Correct 100 ms 8276 KB Output is correct
77 Correct 72 ms 8276 KB Output is correct
78 Correct 652 ms 8248 KB Output is correct
79 Correct 1112 ms 7784 KB Output is correct
80 Execution timed out 3035 ms 7252 KB Time limit exceeded
81 Halted 0 ms 0 KB -