Submission #1033921

# Submission time Handle Problem Language Result Execution time Memory
1033921 2024-07-25T07:46:23 Z vjudge1 Art Exhibition (JOI18_art) C++17
100 / 100
379 ms 12116 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define el '\n'
#define pb push_back
#define mp make_pair
#define niggers                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file(name)                    \
    freopen(name ".inp", "r", stdin); \
    freopen(name ".out", "w", stdout);

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

const ll MOD = 1e9 + 7;
const int inf = 1e9;
const int mxN = 1e2 + 5;
const int mxM = 1e3 + 5;
const int N = 5e5 + 5;

int hx[] = {-1, 0, 1, 0};
int hy[] = {0, 1, 0, -1};

ll pfs[N];
int main()
{
    // freopen("b.inp", "r", stdin);
    // freopen("b.out", "w", stdout);
    ll pinkkiu = 1;
    // cin >> pinkkiu;
    while (pinkkiu--)
    {
        ll n;
        cin >> n;
        pll a[n + 5];
        for (int i = 1; i <= n; ++i)
        {
            cin >> a[i].fi >> a[i].se;
        }
        ll ps[n + 5];
        sort(a + 1, a + n + 1);
        for (int i = 1; i <= n; ++i)
        {
            pfs[i] = pfs[i - 1] + a[i].se;
        }
        ll mn = inf;
        ll ans = 0;
        for (int i = 1; i <= n; i++)
        {
            mn = min(mn, pfs[i - 1] - a[i].fi);
            ans = max(ans, pfs[i] - a[i].fi - mn);
        }
        cout << ans;
    }
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:49:12: warning: unused variable 'ps' [-Wunused-variable]
   49 |         ll ps[n + 5];
      |            ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 3 ms 344 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Correct 5 ms 348 KB Output is correct
34 Correct 3 ms 348 KB Output is correct
35 Correct 4 ms 348 KB Output is correct
36 Correct 4 ms 348 KB Output is correct
37 Correct 4 ms 348 KB Output is correct
38 Correct 3 ms 348 KB Output is correct
39 Correct 3 ms 348 KB Output is correct
40 Correct 3 ms 348 KB Output is correct
41 Correct 3 ms 348 KB Output is correct
42 Correct 3 ms 348 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 4 ms 348 KB Output is correct
45 Correct 5 ms 348 KB Output is correct
46 Correct 3 ms 428 KB Output is correct
47 Correct 3 ms 348 KB Output is correct
48 Correct 4 ms 348 KB Output is correct
49 Correct 3 ms 512 KB Output is correct
50 Correct 3 ms 348 KB Output is correct
51 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 3 ms 344 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Correct 5 ms 348 KB Output is correct
34 Correct 3 ms 348 KB Output is correct
35 Correct 4 ms 348 KB Output is correct
36 Correct 4 ms 348 KB Output is correct
37 Correct 4 ms 348 KB Output is correct
38 Correct 3 ms 348 KB Output is correct
39 Correct 3 ms 348 KB Output is correct
40 Correct 3 ms 348 KB Output is correct
41 Correct 3 ms 348 KB Output is correct
42 Correct 3 ms 348 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 4 ms 348 KB Output is correct
45 Correct 5 ms 348 KB Output is correct
46 Correct 3 ms 428 KB Output is correct
47 Correct 3 ms 348 KB Output is correct
48 Correct 4 ms 348 KB Output is correct
49 Correct 3 ms 512 KB Output is correct
50 Correct 3 ms 348 KB Output is correct
51 Correct 3 ms 344 KB Output is correct
52 Correct 319 ms 12080 KB Output is correct
53 Correct 321 ms 12116 KB Output is correct
54 Correct 306 ms 12080 KB Output is correct
55 Correct 305 ms 12116 KB Output is correct
56 Correct 322 ms 12076 KB Output is correct
57 Correct 319 ms 12112 KB Output is correct
58 Correct 312 ms 12116 KB Output is correct
59 Correct 305 ms 12092 KB Output is correct
60 Correct 371 ms 12096 KB Output is correct
61 Correct 308 ms 12116 KB Output is correct
62 Correct 287 ms 12116 KB Output is correct
63 Correct 334 ms 12112 KB Output is correct
64 Correct 318 ms 12060 KB Output is correct
65 Correct 326 ms 12084 KB Output is correct
66 Correct 313 ms 12116 KB Output is correct
67 Correct 316 ms 12092 KB Output is correct
68 Correct 379 ms 12076 KB Output is correct