# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
483207 | keertan | Global Warming (CEOI18_glo) | C++17 | 114 ms | 17884 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <algorithm>
#include "bits/stdc++.h"
using namespace std;
typedef pair<long long, long long> pii;
int N;
vector<pii> candies;
vector<long long> wagons;
vector<pair<pii, int> > output;
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
long long p, t;
scanf("%lld%lld", &p, &t);
candies.push_back(pii(p + t, -t + p));
}
sort(candies.begin(), candies.end());
for (int i = 0; i < N; i++) {
long long a = candies[i].first, b = candies[i].second;
int pos = lower_bound(wagons.begin(), wagons.end(), b) - wagons.begin();
if (pos == (int) wagons.size()) {
wagons.push_back(b);
} else {
wagons[pos] = b;
}
output.push_back(make_pair(pii((a + b) / 2, (a - b) / 2), pos + 1));
}
printf("%d\n", wagons.size());
for (int i = 0; i < N; i++) {
printf("%lld %lld %d\n", output[i].first.first, output[i].first.second, output[i].second);
}
return 0;
}
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... |