Submission #505010

# Submission time Handle Problem Language Result Execution time Memory
505010 2022-01-10T11:41:14 Z Andy__Andy__ Art Exhibition (JOI18_art) C++17
100 / 100
548 ms 32584 KB
#include <bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;

ifstream f ("test.in");
ofstream g ("test.out");

pair < int ,int > v[500005];
int sum[500005];
int B[500005];
int Bmin[500005];


main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        int valoare ,marime;
        cin>>marime >> valoare;
        v[i]={marime,valoare};
    }

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

    for(int i=1;i<=n;++i) sum[i] = sum[i-1] + v[i].second;

    for(int i=1;i<=n;++i) B[i] = -sum[i] + v[i].first;

    Bmin[n] = B[n];
    for(int i=n-1;i;i--) Bmin[i] = min(B[i],Bmin[1+i]);

    int ans = 0;

    for(int i=1;i<=n;++i)
    {
        /*
        int tmp = sum[j] - sum[i-1] - v[j].first + v[i].first;
        ans = max(ans, tmp);*/
        int tmp = v[i].first - sum[i-1] - Bmin[i];
        ans = max(ans,tmp);
    }

    cout<<ans;

    return 0;
}

Compilation message

art.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 380 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 380 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 380 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 6 ms 508 KB Output is correct
28 Correct 6 ms 460 KB Output is correct
29 Correct 5 ms 460 KB Output is correct
30 Correct 6 ms 460 KB Output is correct
31 Correct 6 ms 460 KB Output is correct
32 Correct 7 ms 460 KB Output is correct
33 Correct 6 ms 460 KB Output is correct
34 Correct 5 ms 460 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 6 ms 460 KB Output is correct
37 Correct 6 ms 500 KB Output is correct
38 Correct 7 ms 460 KB Output is correct
39 Correct 7 ms 460 KB Output is correct
40 Correct 6 ms 460 KB Output is correct
41 Correct 8 ms 496 KB Output is correct
42 Correct 6 ms 520 KB Output is correct
43 Correct 8 ms 460 KB Output is correct
44 Correct 7 ms 460 KB Output is correct
45 Correct 6 ms 460 KB Output is correct
46 Correct 6 ms 488 KB Output is correct
47 Correct 5 ms 460 KB Output is correct
48 Correct 6 ms 460 KB Output is correct
49 Correct 7 ms 460 KB Output is correct
50 Correct 7 ms 500 KB Output is correct
51 Correct 6 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 380 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 6 ms 508 KB Output is correct
28 Correct 6 ms 460 KB Output is correct
29 Correct 5 ms 460 KB Output is correct
30 Correct 6 ms 460 KB Output is correct
31 Correct 6 ms 460 KB Output is correct
32 Correct 7 ms 460 KB Output is correct
33 Correct 6 ms 460 KB Output is correct
34 Correct 5 ms 460 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 6 ms 460 KB Output is correct
37 Correct 6 ms 500 KB Output is correct
38 Correct 7 ms 460 KB Output is correct
39 Correct 7 ms 460 KB Output is correct
40 Correct 6 ms 460 KB Output is correct
41 Correct 8 ms 496 KB Output is correct
42 Correct 6 ms 520 KB Output is correct
43 Correct 8 ms 460 KB Output is correct
44 Correct 7 ms 460 KB Output is correct
45 Correct 6 ms 460 KB Output is correct
46 Correct 6 ms 488 KB Output is correct
47 Correct 5 ms 460 KB Output is correct
48 Correct 6 ms 460 KB Output is correct
49 Correct 7 ms 460 KB Output is correct
50 Correct 7 ms 500 KB Output is correct
51 Correct 6 ms 460 KB Output is correct
52 Correct 548 ms 19848 KB Output is correct
53 Correct 546 ms 32372 KB Output is correct
54 Correct 519 ms 32416 KB Output is correct
55 Correct 494 ms 32400 KB Output is correct
56 Correct 498 ms 32468 KB Output is correct
57 Correct 529 ms 32536 KB Output is correct
58 Correct 496 ms 32568 KB Output is correct
59 Correct 504 ms 32400 KB Output is correct
60 Correct 482 ms 32440 KB Output is correct
61 Correct 481 ms 32552 KB Output is correct
62 Correct 512 ms 32400 KB Output is correct
63 Correct 492 ms 32400 KB Output is correct
64 Correct 486 ms 32584 KB Output is correct
65 Correct 523 ms 32404 KB Output is correct
66 Correct 486 ms 32492 KB Output is correct
67 Correct 484 ms 32504 KB Output is correct
68 Correct 489 ms 32516 KB Output is correct