이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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... |