This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Patryk Niemczyk art.cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
vector<pair<long long, int>> input(n); // INDEKSY OD 0
vector<long long> sp(n + 1, 0); // INDEKSY OD 1
for (int i = 0; i < n; ++i)
cin >> input[i].first >> input[i].second;
sort(input.begin(), input.end());
for (int i = 1; i <= n; ++i)
sp[i] = sp[i - 1] + input[i - 1].second;
long long wynik = 0;
for (int lewy = 0; lewy < n; ++lewy)
for (int prawy = 0; prawy < n; ++prawy)
if (prawy >= lewy)
wynik = max(wynik, (long long)(sp[prawy + 1] - sp[lewy] - input[prawy].first + input[lewy].first));
cout << wynik << '\n';
return 0;
}
// PS. Wiem, ze nie wejdzie na 100
# | 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... |