제출 #1122443

#제출 시각아이디문제언어결과실행 시간메모리
1122443AnhPhamFuel Station (NOI20_fuelstation)C++20
20 / 100
152 ms7240 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; bool operator < (const FUELSTATION &other) const { return (X == other.X ? A < other.A : X < other.X); } }; int N, D; vector <FUELSTATION> stations; namespace sub1 { bool check_condition() { return N == 1; } void solve() { cout << (max(stations[0].X, D - stations[0].A) <= stations[0].B ? max(stations[0].X, D - stations[0].A) : D) << '\n'; } } namespace sub2 { bool check_condition() { for (auto item : stations) if (item.B != 1e9) return 0; return 1; } void solve() { sort(all(stations)); int ans = 0; int sum = 0; for (int i = 0; i < N; ++i) { ans = max(ans, stations[i].X - sum); sum += stations[i].A; } ans = max(ans, D - sum); 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(); else if (sub2 :: check_condition) sub2 :: solve(); }

컴파일 시 표준 에러 (stderr) 메시지

FuelStation.cpp: In function 'int32_t main()':
FuelStation.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(CODE".inp", "r", stdin), freopen(CODE".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
FuelStation.cpp:17:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(CODE".inp", "r", stdin), freopen(CODE".out", "w", stdout);
      |                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...