Submission #1190615

#TimeUsernameProblemLanguageResultExecution timeMemory
1190615emil_aliyevvArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
#define Bismillah ios_base::sync_with_stdio(0);cin.tie(0);
#define indexed_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;

const int N = 5e5 + 7;
const int INF = 1e18;
const int MOD = 998244353;

int n , a[N] , b[N];
vector < pair < int , int > > v;

signed main()
{
    Bismillah;
    // freopen("closing.in", "r", stdin);
    // freopen("closing.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        v.push_back({a[i] , b[i]});
    }
    sort(v.begin() , v.end());
    int pref[n];
    for(int i = 0; i < n; i++)
    {
        pref[i] = (i == 0 ? v[i].second : pref[i - 1] + v[i].second);
    }
    int res = -1;
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            int sum = pref[j] - (i == 0 ? 0 : pref[i - 1]);
            res = max(res , (sum - (v[j].first - v[i].first)));
        }
    }
    cout << res << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...