답안 #876597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876597 2023-11-22T04:00:42 Z hasan2006 Art Exhibition (JOI18_art) C++17
100 / 100
145 ms 34764 KB
#include <bits/stdc++.h>

using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 5e5 + 9 , mod = 1e9 + 7;
ll   a[N] = {}, b[N] , c[N] , d[N] , dp[N];

void solve()
{
    ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
    cin>>n;
    vector<pair<ll,ll>>v;
    for(i = 1; i <= n; i++){
        cin>>a[i]>>b[i];
        v.pb({a[i] , b[i]});
    }
    sort(all(v));
    dp[0] =  mx = v[0].se;
    for(i = 1; i < v.size(); i++){
        dp[i] = max(v[i].se , dp[i - 1] - (v[i].fi - v[i - 1].fi) + v[i].se);
        mx = max(mx , dp[i]);
    }
    cout<<mx;
}

int main(){
    TL;
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
int t = 1;
//cin>>t;
while(t--)
     {
     solve();
     }
}
// Author : حسن

Compilation message

art.cpp: In function 'void solve()':
art.cpp:35:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(i = 1; i < v.size(); i++){
      |                ~~^~~~~~~~~~
art.cpp:26:8: warning: unused variable 'q' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |        ^
art.cpp:26:16: warning: unused variable 'j' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                ^
art.cpp:26:20: warning: unused variable 'm' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                    ^
art.cpp:26:26: warning: unused variable 'z' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                          ^
art.cpp:26:29: warning: unused variable 's' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                             ^
art.cpp:26:37: warning: unused variable 'f' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                     ^
art.cpp:26:40: warning: unused variable 'l' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                        ^
art.cpp:26:44: warning: unused variable 'r' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                            ^
art.cpp:26:48: warning: unused variable 'k' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                ^
art.cpp:26:52: warning: unused variable 'x' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                    ^
art.cpp:26:56: warning: unused variable 'y' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                        ^
art.cpp:26:60: warning: unused variable 'mn' [-Wunused-variable]
   26 |     ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e18 , mx = 0;
      |                                                            ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4560 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4564 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4560 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4564 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4568 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4560 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4564 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4568 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 2 ms 4700 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 2 ms 4700 KB Output is correct
30 Correct 2 ms 4700 KB Output is correct
31 Correct 2 ms 4828 KB Output is correct
32 Correct 2 ms 4700 KB Output is correct
33 Correct 2 ms 4700 KB Output is correct
34 Correct 2 ms 4700 KB Output is correct
35 Correct 2 ms 4700 KB Output is correct
36 Correct 2 ms 4700 KB Output is correct
37 Correct 2 ms 4704 KB Output is correct
38 Correct 2 ms 4700 KB Output is correct
39 Correct 2 ms 4700 KB Output is correct
40 Correct 2 ms 4700 KB Output is correct
41 Correct 2 ms 4700 KB Output is correct
42 Correct 2 ms 4696 KB Output is correct
43 Correct 3 ms 4696 KB Output is correct
44 Correct 2 ms 4700 KB Output is correct
45 Correct 2 ms 4700 KB Output is correct
46 Correct 2 ms 4796 KB Output is correct
47 Correct 2 ms 4700 KB Output is correct
48 Correct 2 ms 4700 KB Output is correct
49 Correct 2 ms 4700 KB Output is correct
50 Correct 2 ms 4700 KB Output is correct
51 Correct 2 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4560 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4564 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4568 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 2 ms 4700 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 2 ms 4700 KB Output is correct
30 Correct 2 ms 4700 KB Output is correct
31 Correct 2 ms 4828 KB Output is correct
32 Correct 2 ms 4700 KB Output is correct
33 Correct 2 ms 4700 KB Output is correct
34 Correct 2 ms 4700 KB Output is correct
35 Correct 2 ms 4700 KB Output is correct
36 Correct 2 ms 4700 KB Output is correct
37 Correct 2 ms 4704 KB Output is correct
38 Correct 2 ms 4700 KB Output is correct
39 Correct 2 ms 4700 KB Output is correct
40 Correct 2 ms 4700 KB Output is correct
41 Correct 2 ms 4700 KB Output is correct
42 Correct 2 ms 4696 KB Output is correct
43 Correct 3 ms 4696 KB Output is correct
44 Correct 2 ms 4700 KB Output is correct
45 Correct 2 ms 4700 KB Output is correct
46 Correct 2 ms 4796 KB Output is correct
47 Correct 2 ms 4700 KB Output is correct
48 Correct 2 ms 4700 KB Output is correct
49 Correct 2 ms 4700 KB Output is correct
50 Correct 2 ms 4700 KB Output is correct
51 Correct 2 ms 4700 KB Output is correct
52 Correct 143 ms 34308 KB Output is correct
53 Correct 136 ms 34764 KB Output is correct
54 Correct 137 ms 34224 KB Output is correct
55 Correct 132 ms 34404 KB Output is correct
56 Correct 135 ms 34236 KB Output is correct
57 Correct 133 ms 34368 KB Output is correct
58 Correct 131 ms 34360 KB Output is correct
59 Correct 134 ms 34672 KB Output is correct
60 Correct 132 ms 34228 KB Output is correct
61 Correct 133 ms 34236 KB Output is correct
62 Correct 130 ms 34744 KB Output is correct
63 Correct 132 ms 34284 KB Output is correct
64 Correct 132 ms 34440 KB Output is correct
65 Correct 132 ms 34260 KB Output is correct
66 Correct 136 ms 34656 KB Output is correct
67 Correct 145 ms 34332 KB Output is correct
68 Correct 134 ms 34212 KB Output is correct