답안 #556182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556182 2022-05-02T14:50:59 Z n0sk1ll Art Exhibition (JOI18_art) C++14
100 / 100
190 ms 12844 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) (x).begin(),(x).end()
#define erase_uni(x) x.erase(unique(all(x)),x.end())
#define inv(n) power((n), mod - 2)
#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)
#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)
#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)
#define sum_overflow(a,b) __builtin_add_overflow_p ((a), (b), (__typeof__ ((a) + (b))) 0)
#define mul_overflow(a,b) __builtin_mul_overflow_p ((a), (b), (__typeof__ ((a) + (b))) 0)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;

/*using namespace __gnu_pbds;
template <class T> using oset = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <class T> using omset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;*/







//Note to self: Check for overflow

pli sta[500005];

int main()
{
    FAST;

    int n; cin>>n;
    ff(i,0,n) cin>>sta[i].xx>>sta[i].yy;

    li ans=0;
    sort(sta,sta+n);
    li lol=0,mince=-sta[0].xx;
    ff(i,0,n)
    {
        lol+=sta[i].yy;
        ans=max(ans,lol-sta[i].xx-mince);
        mince=min(mince,lol-sta[i+1].xx);
    }

    cout<<ans<<"\n";
}

//Note to self: Check for overflow

Compilation message

art.cpp: In function 'int main()':
art.cpp:16:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
art.cpp:54:5: note: in expansion of macro 'ff'
   54 |     ff(i,0,n) cin>>sta[i].xx>>sta[i].yy;
      |     ^~
art.cpp:16:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
art.cpp:59:5: note: in expansion of macro 'ff'
   59 |     ff(i,0,n)
      |     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 324 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 324 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 516 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 520 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 3 ms 472 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 472 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 3 ms 464 KB Output is correct
49 Correct 2 ms 468 KB Output is correct
50 Correct 2 ms 468 KB Output is correct
51 Correct 3 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 324 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 516 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 520 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 3 ms 472 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 472 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 2 ms 468 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 3 ms 464 KB Output is correct
49 Correct 2 ms 468 KB Output is correct
50 Correct 2 ms 468 KB Output is correct
51 Correct 3 ms 464 KB Output is correct
52 Correct 173 ms 9524 KB Output is correct
53 Correct 170 ms 12712 KB Output is correct
54 Correct 176 ms 12688 KB Output is correct
55 Correct 175 ms 12752 KB Output is correct
56 Correct 167 ms 12740 KB Output is correct
57 Correct 172 ms 12740 KB Output is correct
58 Correct 171 ms 12728 KB Output is correct
59 Correct 171 ms 12620 KB Output is correct
60 Correct 181 ms 12692 KB Output is correct
61 Correct 171 ms 12744 KB Output is correct
62 Correct 179 ms 12844 KB Output is correct
63 Correct 175 ms 12684 KB Output is correct
64 Correct 177 ms 12820 KB Output is correct
65 Correct 173 ms 12788 KB Output is correct
66 Correct 190 ms 12724 KB Output is correct
67 Correct 177 ms 12740 KB Output is correct
68 Correct 182 ms 12640 KB Output is correct