답안 #92114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92114 2019-01-01T14:59:23 Z karma Art Exhibition (JOI18_art) C++11
100 / 100
433 ms 29040 KB
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e6 + 7;

ll n, a[N], b[N], s[N], Min, res;
vector<ll> v;

void Enter()
{
     Cin(n);
     For(i, 1, n) Cin(a[i], b[i]), v.pb(a[i]);
     sort(v.begin(), v.end());
     v.erase(unique(v.begin(), v.end()), v.end());
}

void Solve()
{
     For(i, 1, n)
     {
         a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
         s[a[i]] += b[i];
     }
     Min = (ll)1e15; res = 0;
     for(int i = 1; i <= int(v.size()); ++i)
     {
         s[i] += s[i - 1];
         Min = min(s[i - 1] - v[i - 1], Min);
         res = max(res, s[i] - v[i - 1] - Min);
     }
     cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 420 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 420 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
28 Correct 4 ms 752 KB Output is correct
29 Correct 4 ms 760 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 4 ms 760 KB Output is correct
32 Correct 4 ms 688 KB Output is correct
33 Correct 4 ms 760 KB Output is correct
34 Correct 3 ms 632 KB Output is correct
35 Correct 4 ms 636 KB Output is correct
36 Correct 4 ms 632 KB Output is correct
37 Correct 4 ms 760 KB Output is correct
38 Correct 4 ms 632 KB Output is correct
39 Correct 4 ms 760 KB Output is correct
40 Correct 4 ms 632 KB Output is correct
41 Correct 4 ms 760 KB Output is correct
42 Correct 4 ms 760 KB Output is correct
43 Correct 4 ms 764 KB Output is correct
44 Correct 4 ms 632 KB Output is correct
45 Correct 4 ms 632 KB Output is correct
46 Correct 4 ms 764 KB Output is correct
47 Correct 4 ms 760 KB Output is correct
48 Correct 4 ms 632 KB Output is correct
49 Correct 4 ms 760 KB Output is correct
50 Correct 4 ms 760 KB Output is correct
51 Correct 4 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 420 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
28 Correct 4 ms 752 KB Output is correct
29 Correct 4 ms 760 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 4 ms 760 KB Output is correct
32 Correct 4 ms 688 KB Output is correct
33 Correct 4 ms 760 KB Output is correct
34 Correct 3 ms 632 KB Output is correct
35 Correct 4 ms 636 KB Output is correct
36 Correct 4 ms 632 KB Output is correct
37 Correct 4 ms 760 KB Output is correct
38 Correct 4 ms 632 KB Output is correct
39 Correct 4 ms 760 KB Output is correct
40 Correct 4 ms 632 KB Output is correct
41 Correct 4 ms 760 KB Output is correct
42 Correct 4 ms 760 KB Output is correct
43 Correct 4 ms 764 KB Output is correct
44 Correct 4 ms 632 KB Output is correct
45 Correct 4 ms 632 KB Output is correct
46 Correct 4 ms 764 KB Output is correct
47 Correct 4 ms 760 KB Output is correct
48 Correct 4 ms 632 KB Output is correct
49 Correct 4 ms 760 KB Output is correct
50 Correct 4 ms 760 KB Output is correct
51 Correct 4 ms 632 KB Output is correct
52 Correct 262 ms 28800 KB Output is correct
53 Correct 255 ms 29040 KB Output is correct
54 Correct 251 ms 28896 KB Output is correct
55 Correct 250 ms 28768 KB Output is correct
56 Correct 251 ms 28776 KB Output is correct
57 Correct 255 ms 28912 KB Output is correct
58 Correct 259 ms 28796 KB Output is correct
59 Correct 265 ms 28896 KB Output is correct
60 Correct 253 ms 28896 KB Output is correct
61 Correct 257 ms 28648 KB Output is correct
62 Correct 254 ms 28772 KB Output is correct
63 Correct 266 ms 28764 KB Output is correct
64 Correct 328 ms 28896 KB Output is correct
65 Correct 255 ms 28832 KB Output is correct
66 Correct 251 ms 28768 KB Output is correct
67 Correct 433 ms 28852 KB Output is correct
68 Correct 248 ms 28896 KB Output is correct