답안 #551756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
551756 2022-04-21T12:46:55 Z beedle Art Exhibition (JOI18_art) C++17
100 / 100
204 ms 32460 KB
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <stack>
#include <map>
#include <math.h>
#include <bitset>
#include <deque>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#define pi 3.141592653589793238
#define ll long long
#define ld long double
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define mod 998244353ll
#define INF 1000000000000000000
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin (), (x).end ()
#define sz(x) (ll) (x).size ()
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())
#define rank rnk
#define log lg
#define fast                                                                  \
    ios_base::sync_with_stdio (false);                                        \
    cin.tie (NULL);                                                           \
    cout.tie (NULL)

using namespace std;

signed main()
{
    fast;

    // freopen("milkorder.in","r",stdin);
    // freopen("milkorder.out","w",stdout);

    ll n;
    cin>>n;

    pair <ll,ll> p[n+1];

    rep(i,1,n)
    cin>>p[i].ff>>p[i].ss;

    sort(p+1,p+n+1);

    ll csum[n+1];
    csum[0]=0;
    rep(i,1,n)
    csum[i]=csum[i-1]+p[i].ss;

    ll val[n+1];
    val[0]=0;
    rep(i,1,n)
    val[i]=csum[i]-p[i].ff;

    ll mx[n+1];
    mx[n]=val[n];
    for(ll i=n-1;i>=1;--i)
    mx[i]=max(mx[i+1],val[i]);

    ll ans=-INF;
    rep(i,1,n)
    ans=max(ans,mx[i]-(csum[i-1]-p[i].ff));

    cout<<ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 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 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 3 ms 520 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 2 ms 516 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 2 ms 596 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 3 ms 596 KB Output is correct
36 Correct 2 ms 588 KB Output is correct
37 Correct 2 ms 596 KB Output is correct
38 Correct 3 ms 636 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 2 ms 596 KB Output is correct
41 Correct 3 ms 592 KB Output is correct
42 Correct 3 ms 516 KB Output is correct
43 Correct 3 ms 584 KB Output is correct
44 Correct 2 ms 588 KB Output is correct
45 Correct 2 ms 596 KB Output is correct
46 Correct 2 ms 592 KB Output is correct
47 Correct 2 ms 596 KB Output is correct
48 Correct 2 ms 520 KB Output is correct
49 Correct 2 ms 520 KB Output is correct
50 Correct 2 ms 596 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 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 0 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 3 ms 520 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 2 ms 516 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 2 ms 596 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 3 ms 596 KB Output is correct
36 Correct 2 ms 588 KB Output is correct
37 Correct 2 ms 596 KB Output is correct
38 Correct 3 ms 636 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 2 ms 596 KB Output is correct
41 Correct 3 ms 592 KB Output is correct
42 Correct 3 ms 516 KB Output is correct
43 Correct 3 ms 584 KB Output is correct
44 Correct 2 ms 588 KB Output is correct
45 Correct 2 ms 596 KB Output is correct
46 Correct 2 ms 592 KB Output is correct
47 Correct 2 ms 596 KB Output is correct
48 Correct 2 ms 520 KB Output is correct
49 Correct 2 ms 520 KB Output is correct
50 Correct 2 ms 596 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 184 ms 32436 KB Output is correct
53 Correct 194 ms 32440 KB Output is correct
54 Correct 186 ms 32452 KB Output is correct
55 Correct 188 ms 32440 KB Output is correct
56 Correct 181 ms 32436 KB Output is correct
57 Correct 186 ms 32420 KB Output is correct
58 Correct 183 ms 32428 KB Output is correct
59 Correct 181 ms 32440 KB Output is correct
60 Correct 189 ms 32436 KB Output is correct
61 Correct 184 ms 32332 KB Output is correct
62 Correct 189 ms 32432 KB Output is correct
63 Correct 183 ms 32448 KB Output is correct
64 Correct 204 ms 32416 KB Output is correct
65 Correct 192 ms 32416 KB Output is correct
66 Correct 197 ms 32460 KB Output is correct
67 Correct 191 ms 32444 KB Output is correct
68 Correct 188 ms 32432 KB Output is correct