# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96241 | pamaj | Art Exhibition (JOI18_art) | C++14 | 2 ms | 376 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 <bits/stdc++.h>
using namespace std;
typedef uint64_t ll;
const int maxn = 5e5 + 10;;
ll n, pref[maxn];
vector<pair<ll, ll>> v;
int main()
{
ios::sync_with_stdio(false), cin.tie(nullptr);
cin >> n;
for(int i = 0; i < n; i++)
{
ll a, b;
cin >> a >> b;
v.push_back({a, b});
}
sort(v.begin(), v.end());
// for(int i = 0; i < n; i++)
// {
// if(!i) pref[i] = v[i].second;
// else
// {
// pref[i] = pref[i - 1] + v[i].second;
// }
// }
ll ans = 0;
for(int i = 0; i < n - 1; i++)
{
ll sum = v[i].second;
for(int j = i + 1; j < n; j++)
{
sum += v[j].second;
ans = max(ans, sum - (v[j].first- v[i].first));
}
}
cout << ans << "\n";
}
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... |