# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1122538 | AnhPham | Bikeparking (EGOI24_bikeparking) | C++20 | 44 ms | 5108 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 **/
const int mxN = 3e5 + 5;
int N;
int X[mxN], Y[mxN];
namespace sub12 {
bool check_condition() {
return ((N == 2 && *max_element(X, X + N) <= 100 && *max_element(Y, Y + N) <= 100) ||
(*min_element(X, X + N) == *max_element(X, X + N) && *min_element(Y, Y + N) == *max_element(Y, Y + N)));
}
void solve() {
int ans = 0;
int ptr = 0;
for (int i = 0; i < N; ++i) {
while (X[ptr] == 0)
ptr++;
if (ptr >= i)
continue;
int val = min(X[ptr], Y[i]);
X[ptr] -= val;
Y[i] -= val;
ans += val;
}
for (int i = 0; i < N; ++i) {
int val = min(X[i], Y[i]);
X[i] -= val;
Y[i] -= val;
}
for (int i = 0; i < N; ++i)
ans -= Y[i];
cout << ans << '\n';
}
}
void solve() {
cin >> N;
for (int i = 0; i < N; ++i)
cin >> X[i];
for (int i = 0; i < N; ++i)
cin >> Y[i];
if (sub12 :: check_condition())
sub12 :: solve();
}
컴파일 시 표준 에러 (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... |