답안 #548839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548839 2022-04-14T13:13:42 Z idas Art Exhibition (JOI18_art) C++11
50 / 100
30 ms 964 KB
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef long long ll;

const int N=5e3+10;
int n;
vi in;
ll a[N], b[N], p[N];

bool cmp(int i, int j)
{
    return a[i]<=a[j];
}

int main()
{
    cin >> n;
    FOR(i, 0, n)
    {
        cin >> a[i] >> b[i];
        in.pb(i);
    }

    sort(in.begin(), in.end(), cmp);

    FOR(k, 0, n)
    {
        int i=in[k];
        p[k+1]=p[k]+b[i];
    }

    ll ans=0;
    FOR(k, 0, n)
    {
        int i=in[k];
        //cout << a[i] << " " << b[i] << endl;
        FOR(b, k, n)
        {
            int j=in[b];
            ll sum=p[b+1]-p[k];
            //cout << k << " " << b << " " << sum << endl;
            ans=max(ans, sum-a[j]+a[i]);
        }
    }

    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 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 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 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 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 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 340 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 316 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 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 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 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 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 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 340 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 316 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 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 23 ms 596 KB Output is correct
28 Correct 21 ms 596 KB Output is correct
29 Correct 21 ms 468 KB Output is correct
30 Correct 22 ms 556 KB Output is correct
31 Correct 22 ms 596 KB Output is correct
32 Correct 21 ms 596 KB Output is correct
33 Correct 24 ms 584 KB Output is correct
34 Correct 22 ms 596 KB Output is correct
35 Correct 23 ms 604 KB Output is correct
36 Correct 22 ms 580 KB Output is correct
37 Correct 29 ms 600 KB Output is correct
38 Correct 24 ms 596 KB Output is correct
39 Correct 23 ms 596 KB Output is correct
40 Correct 23 ms 560 KB Output is correct
41 Correct 21 ms 468 KB Output is correct
42 Correct 23 ms 572 KB Output is correct
43 Correct 21 ms 596 KB Output is correct
44 Correct 26 ms 596 KB Output is correct
45 Correct 21 ms 596 KB Output is correct
46 Correct 24 ms 564 KB Output is correct
47 Correct 30 ms 564 KB Output is correct
48 Correct 24 ms 596 KB Output is correct
49 Correct 21 ms 596 KB Output is correct
50 Correct 21 ms 576 KB Output is correct
51 Correct 21 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 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 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 340 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 316 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 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 23 ms 596 KB Output is correct
28 Correct 21 ms 596 KB Output is correct
29 Correct 21 ms 468 KB Output is correct
30 Correct 22 ms 556 KB Output is correct
31 Correct 22 ms 596 KB Output is correct
32 Correct 21 ms 596 KB Output is correct
33 Correct 24 ms 584 KB Output is correct
34 Correct 22 ms 596 KB Output is correct
35 Correct 23 ms 604 KB Output is correct
36 Correct 22 ms 580 KB Output is correct
37 Correct 29 ms 600 KB Output is correct
38 Correct 24 ms 596 KB Output is correct
39 Correct 23 ms 596 KB Output is correct
40 Correct 23 ms 560 KB Output is correct
41 Correct 21 ms 468 KB Output is correct
42 Correct 23 ms 572 KB Output is correct
43 Correct 21 ms 596 KB Output is correct
44 Correct 26 ms 596 KB Output is correct
45 Correct 21 ms 596 KB Output is correct
46 Correct 24 ms 564 KB Output is correct
47 Correct 30 ms 564 KB Output is correct
48 Correct 24 ms 596 KB Output is correct
49 Correct 21 ms 596 KB Output is correct
50 Correct 21 ms 576 KB Output is correct
51 Correct 21 ms 596 KB Output is correct
52 Runtime error 7 ms 964 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -