Submission #918290

# Submission time Handle Problem Language Result Execution time Memory
918290 2024-01-29T14:30:56 Z vjudge1 Art Exhibition (JOI18_art) C++14
100 / 100
398 ms 25068 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();

int 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:143:15: warning: unused variable 'mn' [-Wunused-variable]
  143 |     long long mn=a[1].se,s=0,ans=-INF;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 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 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 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 344 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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 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 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 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 344 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 348 KB Output is correct
28 Correct 4 ms 540 KB Output is correct
29 Correct 5 ms 348 KB Output is correct
30 Correct 4 ms 344 KB Output is correct
31 Correct 4 ms 344 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 4 ms 348 KB Output is correct
35 Correct 4 ms 348 KB Output is correct
36 Correct 4 ms 560 KB Output is correct
37 Correct 4 ms 348 KB Output is correct
38 Correct 4 ms 472 KB Output is correct
39 Correct 4 ms 348 KB Output is correct
40 Correct 4 ms 348 KB Output is correct
41 Correct 4 ms 556 KB Output is correct
42 Correct 4 ms 348 KB Output is correct
43 Correct 4 ms 348 KB Output is correct
44 Correct 4 ms 464 KB Output is correct
45 Correct 4 ms 344 KB Output is correct
46 Correct 4 ms 348 KB Output is correct
47 Correct 4 ms 348 KB Output is correct
48 Correct 4 ms 524 KB Output is correct
49 Correct 4 ms 344 KB Output is correct
50 Correct 4 ms 348 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 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 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 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 344 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 348 KB Output is correct
28 Correct 4 ms 540 KB Output is correct
29 Correct 5 ms 348 KB Output is correct
30 Correct 4 ms 344 KB Output is correct
31 Correct 4 ms 344 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 4 ms 348 KB Output is correct
35 Correct 4 ms 348 KB Output is correct
36 Correct 4 ms 560 KB Output is correct
37 Correct 4 ms 348 KB Output is correct
38 Correct 4 ms 472 KB Output is correct
39 Correct 4 ms 348 KB Output is correct
40 Correct 4 ms 348 KB Output is correct
41 Correct 4 ms 556 KB Output is correct
42 Correct 4 ms 348 KB Output is correct
43 Correct 4 ms 348 KB Output is correct
44 Correct 4 ms 464 KB Output is correct
45 Correct 4 ms 344 KB Output is correct
46 Correct 4 ms 348 KB Output is correct
47 Correct 4 ms 348 KB Output is correct
48 Correct 4 ms 524 KB Output is correct
49 Correct 4 ms 344 KB Output is correct
50 Correct 4 ms 348 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
52 Correct 392 ms 19028 KB Output is correct
53 Correct 397 ms 24912 KB Output is correct
54 Correct 390 ms 24656 KB Output is correct
55 Correct 394 ms 24656 KB Output is correct
56 Correct 398 ms 24820 KB Output is correct
57 Correct 391 ms 24824 KB Output is correct
58 Correct 398 ms 25068 KB Output is correct
59 Correct 390 ms 24792 KB Output is correct
60 Correct 395 ms 24792 KB Output is correct
61 Correct 388 ms 24656 KB Output is correct
62 Correct 395 ms 24784 KB Output is correct
63 Correct 394 ms 24656 KB Output is correct
64 Correct 391 ms 24700 KB Output is correct
65 Correct 394 ms 24916 KB Output is correct
66 Correct 391 ms 24652 KB Output is correct
67 Correct 396 ms 24916 KB Output is correct
68 Correct 388 ms 24652 KB Output is correct