# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1122438 | AnhPham | Fuel Station (NOI20_fuelstation) | C++20 | 91 ms | 7240 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
const int MOD = (int)1e9 + 7;
const int INF = (int)4e18 + 18;
void solve();
int32_t main() {
#define CODE "task"
if (fopen(CODE".inp", "r"))
freopen(CODE".inp", "r", stdin), freopen(CODE".out", "w", stdout);
cin.tie(nullptr), cout.tie(nullptr) -> sync_with_stdio(false);
int testcases = 1;
#define multitest 0
if (multitest) { cin >> testcases; } for (; testcases--;) { solve(); }
}
/** [Pham Hung Anh - 12I - Tran Hung Dao High School for Gifted Student] **/
/** The Last Dance **/
struct FUELSTATION {
int X, A, B;
};
int N, D;
vector <FUELSTATION> stations;
namespace sub1 {
bool check_condition() {
return N == 1;
}
void solve() {
int ans = -1;
int lo = stations[0].X, hi = stations[0].B;
while (lo <= hi) {
int mid = (lo + hi) >> 1;
if (mid + stations[0].A >= D)
ans = mid, hi = mid - 1;
else
lo = mid + 1;
}
cout << ans << '\n';
}
}
void solve() {
cin >> N >> D;
stations = vector <FUELSTATION> (N);
for (auto &item : stations)
cin >> item.X >> item.A >> item.B;
if (sub1 :: check_condition())
sub1 :: solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |