Submission #918284

# Submission time Handle Problem Language Result Execution time Memory
918284 2024-01-29T14:25:47 Z vjudge1 Art Exhibition (JOI18_art) C++14
0 / 100
0 ms 348 KB
//******************/
//*   I<3   C++    */
//*  I WANT ANY AC */
//* I LOVE PROGRAM!*/
//*IT'S long longERESTING*/
//* I LOVE PROGRAM!*/
//*  IN CONTESTS   */
//*   GET SCORE    */
//*    AC CODE     */
//*     LET'S      */
//*      GO        */
//*  Written by:   */
//*   Duc Minh     */






#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <string>
#include <queue>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <deque>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define  file(name)  freopen(name".inp", "r", stdin);\
                     freopen(name".out", "w", stdout);
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define TIME        (1.0 * clock() / CLOCKS_PER_SEC)
#define all(a)      a.begin(),a.end()
#define endl        "\n"
#define all1(a)     a+1,a+n+1
#define unordered_map  map
#define Accepted 0      
// #define push_back   emplace_back
// #define gcd(a,b)    __gcd(a,b);
// #define lcm(a,b)    (a*b)/gcd(a,b);

const long long INF = (long long)1e9;
const long long MOD = (long long)1e9+7;
const long long MODD = 14062008; /// 998244353
const long long maxN = 2e5+9;
const long long LOG = 30;







///--------------------------------


void solve();

signed main(){








    long long t;


    // cin >> t;

    t=1;



    while (t--){




        solve();


    }






    return Accepted;
}



///--------------------[PROBLEM SOLUTION]--------------------///



struct minh{

    long long fi,se,pos;
};

bool cmp(minh a, minh b){

    return a.fi<b.fi;
}


minh a[200009];

void solve(){



    long long n;

    cin >> n;

    for (long long i=1; i<=n; i++){
        cin >> a[i].fi >> a[i].se;

        a[i].pos=i;
    }


    sort(a+1,a+n+1,cmp);

    long long mn=a[1].se,s=0,ans=-INF;

    for (long long i=1; i<=n; i++){
        // cout << a[i].fi << ' ' << a[i].se << "\n";
        

        s+=a[i].se;




        if (i!=1) ans=max(ans,s-(a[i].fi-mn));

        mn=min(mn,a[i].fi);
    }

    cout << ans;



}





# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -