Submission #918291

# Submission time Handle Problem Language Result Execution time Memory
918291 2024-01-29T14:31:29 Z phamducminh Art Exhibition (JOI18_art) C++17
100 / 100
433 ms 19044 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[500009];

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";
        

        

        ans=max({ans,s+ a[i].se-a[i].fi,a[i].se});

        s+=a[i].se;
        s=max(s,a[i].fi+a[i].se);


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

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

    cout << ans;



}





Compilation message

art.cpp: In function 'void solve()':
art.cpp:138:15: warning: unused variable 'mn' [-Wunused-variable]
  138 |     long long mn=a[1].se,s=0,ans=-INF;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 444 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 432 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 444 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 432 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 4 ms 564 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 4 ms 608 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 4 ms 600 KB Output is correct
32 Correct 4 ms 600 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 4 ms 604 KB Output is correct
35 Correct 4 ms 604 KB Output is correct
36 Correct 4 ms 600 KB Output is correct
37 Correct 6 ms 604 KB Output is correct
38 Correct 4 ms 452 KB Output is correct
39 Correct 4 ms 604 KB Output is correct
40 Correct 4 ms 604 KB Output is correct
41 Correct 4 ms 604 KB Output is correct
42 Correct 4 ms 604 KB Output is correct
43 Correct 4 ms 612 KB Output is correct
44 Correct 4 ms 604 KB Output is correct
45 Correct 4 ms 636 KB Output is correct
46 Correct 4 ms 644 KB Output is correct
47 Correct 4 ms 600 KB Output is correct
48 Correct 4 ms 856 KB Output is correct
49 Correct 4 ms 600 KB Output is correct
50 Correct 4 ms 600 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 444 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 432 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 4 ms 564 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 4 ms 608 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 4 ms 600 KB Output is correct
32 Correct 4 ms 600 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 4 ms 604 KB Output is correct
35 Correct 4 ms 604 KB Output is correct
36 Correct 4 ms 600 KB Output is correct
37 Correct 6 ms 604 KB Output is correct
38 Correct 4 ms 452 KB Output is correct
39 Correct 4 ms 604 KB Output is correct
40 Correct 4 ms 604 KB Output is correct
41 Correct 4 ms 604 KB Output is correct
42 Correct 4 ms 604 KB Output is correct
43 Correct 4 ms 612 KB Output is correct
44 Correct 4 ms 604 KB Output is correct
45 Correct 4 ms 636 KB Output is correct
46 Correct 4 ms 644 KB Output is correct
47 Correct 4 ms 600 KB Output is correct
48 Correct 4 ms 856 KB Output is correct
49 Correct 4 ms 600 KB Output is correct
50 Correct 4 ms 600 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
52 Correct 394 ms 19044 KB Output is correct
53 Correct 389 ms 18768 KB Output is correct
54 Correct 399 ms 18772 KB Output is correct
55 Correct 396 ms 18788 KB Output is correct
56 Correct 433 ms 18812 KB Output is correct
57 Correct 386 ms 18768 KB Output is correct
58 Correct 382 ms 18768 KB Output is correct
59 Correct 394 ms 19024 KB Output is correct
60 Correct 413 ms 18808 KB Output is correct
61 Correct 422 ms 18528 KB Output is correct
62 Correct 414 ms 18628 KB Output is correct
63 Correct 415 ms 18628 KB Output is correct
64 Correct 390 ms 18804 KB Output is correct
65 Correct 389 ms 18752 KB Output is correct
66 Correct 394 ms 19044 KB Output is correct
67 Correct 387 ms 18804 KB Output is correct
68 Correct 398 ms 19044 KB Output is correct