# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198720 | stormy_weather | Art Exhibition (JOI18_art) | C++14 | 0 ms | 0 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<iostream>
#include<vector>
using namespace std;
int main() {
int n; cin >> n;
vector <pair <int64_t, int>> values(n);
for (int i = 0; i < n; i++) {
cin >> values[i].first >> values[i].second;
}
sort(values.begin(), values.end());
vector <int64_t> p_sum(n);
for (int i = 0; i < n; i++) {
p_sum[i] = i > 0 ? p_sum[i - 1] + values[i].second : values[i].second;
}
//we determine our functions
vector <int64_t> first_part(n), second_part(n);
for (int i = 0; i < n; i++) {
first_part[i] = p_sum[i] - values[i].first;
second_part[i] = i > 0 ? p_sum[i - 1] - values[i].first : -1 * values[i].first;
}
vector <int64_t> min_second_part(n);
int64_t min = second_part[0];
for (int i = 0; i < n; i++) {
if (second_part[i] <= min)