Submission #198720

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1987202020-01-27 13:24:29stormy_weatherArt Exhibition (JOI18_art)C++14
Compilation error
0 ms0 KiB
#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)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:13:3: error: 'sort' was not declared in this scope
   sort(values.begin(), values.end());
   ^~~~
art.cpp:13:3: note: suggested alternative: 'qsort'
   sort(values.begin(), values.end());
   ^~~~
   qsort