# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
770857 | The_Samurai | Potatoes and fertilizers (LMIO19_bulves) | C++17 | 133 ms | 22672 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
void solve() {
int n;
cin >> n;
vector<pair<int, int>> a(n);
set<int> pos;
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
if (a[i].first > a[i].second) {
pos.insert(i);
}
}
int j = 0;
ll ans = 0;
for (int i = 0; i < n; i++) {
if (a[i].first >= a[i].second) {
continue;
}
while (a[i].first < a[i].second) {
while (j < i and a[j].first <= a[j].second) {
j++;
}
if (j != i) {
int x = min(a[i].second - a[i].first, a[j].first - a[j].second);
a[i].first += x;
a[j].first -= x;
# | 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... |