Submission #1108585

# Submission time Handle Problem Language Result Execution time Memory
1108585 2024-11-04T13:59:16 Z vjudge1 Art Exhibition (JOI18_art) C++17
100 / 100
361 ms 8276 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define priority_queue priority_queue<array<long long,2>, vector<array<long long,2>>, greater<array<long long,2>>>
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define pii pair<int,int>
#define pli pair<long long,int> 
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define pi 3.14159265358979323846 
#define pb push_back
#define fi first
#define se second
#define ar array
#define int long long

void chay()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define task "Hi"
    freopen(task".INP", "r", stdin);
    freopen(task".OUT", "w", stdout);
}

const int N = 5e5, INF = 2e9+7;
const int block = 600;
const long long INFLL = 2e18+7;
long long M = 1e9+7;
int n;
ar<int,2> a[N+5];

void solve()
{
	cin>>n;
	for (int i = 1; i <= n; i++)
	{
		cin>>a[i][0]>>a[i][1];
	}
	sort(a+1, a+n+1);
	int d = -a[1][0], kq = a[1][1], tong = 0;
	for (int i = 1; i <= n; i++)
	{
		tong += a[i][1];
		kq = max(kq, tong - a[i][0] - d);
		d = min(d, tong - a[i+1][0]);
	}
	cout<<kq;
}
 
signed main ()
{
    //chay();
    int t = 1;   
    //cin>>t; 
    while (t--)
    {
        solve();
    }

    return 0;
}

Compilation message

art.cpp: In function 'void chay()':
art.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen(task".INP", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen(task".OUT", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 4 ms 336 KB Output is correct
28 Correct 4 ms 508 KB Output is correct
29 Correct 4 ms 336 KB Output is correct
30 Correct 4 ms 336 KB Output is correct
31 Correct 4 ms 336 KB Output is correct
32 Correct 5 ms 336 KB Output is correct
33 Correct 4 ms 336 KB Output is correct
34 Correct 7 ms 348 KB Output is correct
35 Correct 4 ms 336 KB Output is correct
36 Correct 5 ms 336 KB Output is correct
37 Correct 4 ms 336 KB Output is correct
38 Correct 4 ms 488 KB Output is correct
39 Correct 4 ms 336 KB Output is correct
40 Correct 4 ms 336 KB Output is correct
41 Correct 4 ms 336 KB Output is correct
42 Correct 4 ms 336 KB Output is correct
43 Correct 5 ms 336 KB Output is correct
44 Correct 5 ms 336 KB Output is correct
45 Correct 4 ms 336 KB Output is correct
46 Correct 4 ms 336 KB Output is correct
47 Correct 4 ms 336 KB Output is correct
48 Correct 4 ms 336 KB Output is correct
49 Correct 4 ms 336 KB Output is correct
50 Correct 4 ms 336 KB Output is correct
51 Correct 4 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 4 ms 336 KB Output is correct
28 Correct 4 ms 508 KB Output is correct
29 Correct 4 ms 336 KB Output is correct
30 Correct 4 ms 336 KB Output is correct
31 Correct 4 ms 336 KB Output is correct
32 Correct 5 ms 336 KB Output is correct
33 Correct 4 ms 336 KB Output is correct
34 Correct 7 ms 348 KB Output is correct
35 Correct 4 ms 336 KB Output is correct
36 Correct 5 ms 336 KB Output is correct
37 Correct 4 ms 336 KB Output is correct
38 Correct 4 ms 488 KB Output is correct
39 Correct 4 ms 336 KB Output is correct
40 Correct 4 ms 336 KB Output is correct
41 Correct 4 ms 336 KB Output is correct
42 Correct 4 ms 336 KB Output is correct
43 Correct 5 ms 336 KB Output is correct
44 Correct 5 ms 336 KB Output is correct
45 Correct 4 ms 336 KB Output is correct
46 Correct 4 ms 336 KB Output is correct
47 Correct 4 ms 336 KB Output is correct
48 Correct 4 ms 336 KB Output is correct
49 Correct 4 ms 336 KB Output is correct
50 Correct 4 ms 336 KB Output is correct
51 Correct 4 ms 336 KB Output is correct
52 Correct 331 ms 8040 KB Output is correct
53 Correct 338 ms 8028 KB Output is correct
54 Correct 334 ms 8008 KB Output is correct
55 Correct 339 ms 8036 KB Output is correct
56 Correct 361 ms 8008 KB Output is correct
57 Correct 323 ms 8036 KB Output is correct
58 Correct 333 ms 8044 KB Output is correct
59 Correct 323 ms 8008 KB Output is correct
60 Correct 324 ms 8008 KB Output is correct
61 Correct 329 ms 8008 KB Output is correct
62 Correct 328 ms 8188 KB Output is correct
63 Correct 359 ms 8164 KB Output is correct
64 Correct 332 ms 8008 KB Output is correct
65 Correct 342 ms 8008 KB Output is correct
66 Correct 322 ms 8044 KB Output is correct
67 Correct 342 ms 8252 KB Output is correct
68 Correct 330 ms 8276 KB Output is correct