# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
553247 | sandry24 | Art Exhibition (JOI18_art) | C++17 | 0 ms | 212 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 long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
bool cust_sort(ll a, ll b){
}
void solve(){
int n;
cin >> n;
vector<pair<ll, ll>> a(n);
for(int i = 0; i < n; i++)
cin >> a[i].f >> a[i].s;
sort(a.begin(), a.end());
vector<ll> prefix(n);
prefix[0] = a[0].s;
for(int i = 1; i < n; i++)
prefix[i] = a[i].s + prefix[i-1];
ll ans = 0;
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
ll temp = 0;
if(i == 0)
temp += prefix[j];
else
temp += prefix[j] - prefix[i];
temp -= a[j].f - a[i].f;
ans = max(ans, temp);
}
}
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
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... |