답안 #918289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918289 2024-01-29T14:30:11 Z phamducminh Art Exhibition (JOI18_art) C++14
50 / 100
143 ms 10064 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[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";
        

        

        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:140:15: warning: unused variable 'mn' [-Wunused-variable]
  140 |     long long mn=a[1].se,s=0,ans=-INF;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 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 600 KB Output is correct
7 Correct 0 ms 344 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 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 600 KB Output is correct
7 Correct 0 ms 344 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 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 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 600 KB Output is correct
7 Correct 0 ms 344 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 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 4 ms 348 KB Output is correct
29 Correct 5 ms 604 KB Output is correct
30 Correct 5 ms 344 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 4 ms 496 KB Output is correct
33 Correct 5 ms 344 KB Output is correct
34 Correct 4 ms 556 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 4 ms 344 KB Output is correct
37 Correct 4 ms 348 KB Output is correct
38 Correct 4 ms 344 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 356 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 348 KB Output is correct
45 Correct 4 ms 544 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 560 KB Output is correct
49 Correct 4 ms 348 KB Output is correct
50 Correct 4 ms 348 KB Output is correct
51 Correct 4 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 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 600 KB Output is correct
7 Correct 0 ms 344 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 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 4 ms 348 KB Output is correct
29 Correct 5 ms 604 KB Output is correct
30 Correct 5 ms 344 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 4 ms 496 KB Output is correct
33 Correct 5 ms 344 KB Output is correct
34 Correct 4 ms 556 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 4 ms 344 KB Output is correct
37 Correct 4 ms 348 KB Output is correct
38 Correct 4 ms 344 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 356 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 348 KB Output is correct
45 Correct 4 ms 544 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 560 KB Output is correct
49 Correct 4 ms 348 KB Output is correct
50 Correct 4 ms 348 KB Output is correct
51 Correct 4 ms 540 KB Output is correct
52 Runtime error 143 ms 10064 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -