# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1131445 | kem | Bikeparking (EGOI24_bikeparking) | C++20 | 41 ms | 2632 KiB |
#include <bits/stdc++.h>
using namespace std;
#define NAME "name"
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define endl "\n"
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
const int LIM = 3e5 + 3;
const int INF = 1e9 + 9;
const int mod = 1e9 + 7;
int n;
int x[LIM], y[LIM];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (ifstream(NAME ".inp"))
{
freopen(NAME ".inp", "r", stdin);
freopen(NAME ".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++)
cin >> x[i];
for (int i = 1; i <= n; i++)
cin >> y[i];
int pos = 0, nor = 0, neg = 0;
for (int i = n; i >= 1; i--)
{
int res1 = min(neg, x[i]);
neg -= res1, x[i] -= res1;
int res2 = min(nor, x[i]);
nor -= res2, x[i] -= res2;
pos += res1 + res2;
nor += min(x[i], y[i]);
neg += y[i] - min(x[i], y[i]);
}
cout << pos - neg;
return 0;
}
컴파일 시 표준 에러 (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... |