답안 #1050161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050161 2024-08-09T07:46:56 Z vjudge1 Art Exhibition (JOI18_art) C++17
100 / 100
319 ms 24744 KB
#include <bits/stdc++.h>

// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #else
// #define debug(...)
// #define debugArr(...)
// #endif

#pragma region 
#define int long long

#define vec vector
#define vlong vec<long>
#define vint vec<int>
#define vchar vec<char>
#define vbool vec<bool>
#define vvint vec<vint>
#define vstr vec<string>
#define vstring vstr
#define vpint vec<pair<int, int> >

#define CININT(n) INTCIN(n);
#define INTCIN(n) long n; cin >> n;
#define INTCINVINTCIN(a, n) INTCIN(n); vint a(n); CINV(a, n);
#define TWOVECS(a, b, n) INTCIN(n); vint a(n), b(n); CINV(a, n) CINV (b, n);
#define TWOCOLS(a, b, n) INTCIN(n); vint a(n), b(n); CINVV(a, b, n);

#define ICVK(n, k, a) 			CININT(n); CININT(k); vint a(n); CINV(a, n);
#define ICVK1(n, k, a) 			ICVK(n, k, a)
#define ICVK2(n, k, h, a) 		CININT(n); CININT(k); CININT(h); vint a(n); CINV(a, n);
#define ICVK3(n, k, h, m, a)	CININT(n); CININT(k); CININT(h); CININT(m); vint a(n); CINV(a, n);

#define CIN(n) 			cin >> n;
#define COUT(n) 		cout << n;

#define CINV(a, n) 		for (int i = 0; i < n; i++) {cin >> a[i];}
#define CINVV(a, b, n) 	for (int i = 0; i < n; i++) {cin >> a[i] >> b[i];}

#define COUTV(a, n) 	for (int i = 0; i < n; i++) {cout << a[i] << " ";}
#define COUTVV(a, b, n) 	for (int i = 0; i < n; i++) {cout << a[i] << " " << b[i] << "\n";}

#define NOSPACE(a, n) 	for (int i = 0;i < n;i++) {cout << a[i];}
#define ENDL cout << "\n";

#define SORT(a) sort(a.begin(), a.end());
#define REVERSE(a) reverse(a.begin(), a.end());
#define HAS(theset, num) ((theset.find((num)) != (theset.end())))

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR1(i, n) for (int i = 1; i < n; i++)
#define YES if (true) {cout << "YES"; return;}
#define NO if (true) {cout << "NO"; return;}
#define Yes if (true) {cout << "Yes"; return;}
#define No if (true) {cout << "No"; return;}
#define IMPOS if (true) {cout << "Impossible"; return;}
#define IMPOSS IMPOS

#define SP " "
#define NEWLINE "\n"

#define Q int q;cin>>q;while(q--)
#pragma endregion

using namespace std;


void pre() {}

// you can do this!
const bool DO_ENDL = true;
const bool MULTI_T = false; // :skull: dont forgorr me!!
void solve() {
    long n;
    cin >> n;
    vec<pair<int, int> > a(n);

    for (int i = 0; i < n; i++) {
        long x, y;
        cin >> x >> y;
        a[i] = {x, y};
    }

    SORT(a);

    vint val_pfx(n+1);
    for (int i = 1; i <= n; i++) {
        val_pfx[i] = a[i-1].second + val_pfx[i-1];
    }


    
    int ans = 0;
    int bestj = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j <= i; j++) {
            int oldval = -(a[i].first - a[bestj].first) + val_pfx[i+1] - val_pfx[bestj];
            int newval = -(a[i].first - a[j].first) + val_pfx[i+1] - val_pfx[j];
            if (newval > oldval) bestj = j;
            // cout << newval << SP;
        }
        ans = max(ans, 
                -(a[i].first - a[bestj].first) + val_pfx[i+1] - val_pfx[bestj]
            );
        // cout << endl;
        // cout << bestj << SP;
    }




    cout << ans;
}


signed main() {
	pre();
	if (not MULTI_T)
		{solve();
		return 0;}
	
	CININT(t);
	while (t--) {
		solve();
		if (DO_ENDL)
			ENDL;
	}
}

Compilation message

art.cpp:10: warning: ignoring '#pragma region ' [-Wunknown-pragmas]
   10 | #pragma region
      | 
art.cpp:63: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   63 | #pragma endregion
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 0 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 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 0 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 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 348 KB Output is correct
20 Correct 0 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 0 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 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 348 KB Output is correct
20 Correct 0 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 3 ms 348 KB Output is correct
33 Correct 3 ms 348 KB Output is correct
34 Correct 3 ms 512 KB Output is correct
35 Correct 5 ms 348 KB Output is correct
36 Correct 4 ms 348 KB Output is correct
37 Correct 3 ms 348 KB Output is correct
38 Correct 3 ms 344 KB Output is correct
39 Correct 3 ms 348 KB Output is correct
40 Correct 5 ms 348 KB Output is correct
41 Correct 3 ms 416 KB Output is correct
42 Correct 3 ms 348 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 3 ms 344 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 3 ms 348 KB Output is correct
47 Correct 5 ms 344 KB Output is correct
48 Correct 3 ms 348 KB Output is correct
49 Correct 3 ms 508 KB Output is correct
50 Correct 4 ms 344 KB Output is correct
51 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 0 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 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 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 0 ms 348 KB Output is correct
20 Correct 0 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 5 ms 348 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 3 ms 348 KB Output is correct
33 Correct 3 ms 348 KB Output is correct
34 Correct 3 ms 512 KB Output is correct
35 Correct 5 ms 348 KB Output is correct
36 Correct 4 ms 348 KB Output is correct
37 Correct 3 ms 348 KB Output is correct
38 Correct 3 ms 344 KB Output is correct
39 Correct 3 ms 348 KB Output is correct
40 Correct 5 ms 348 KB Output is correct
41 Correct 3 ms 416 KB Output is correct
42 Correct 3 ms 348 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 3 ms 344 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 3 ms 348 KB Output is correct
47 Correct 5 ms 344 KB Output is correct
48 Correct 3 ms 348 KB Output is correct
49 Correct 3 ms 508 KB Output is correct
50 Correct 4 ms 344 KB Output is correct
51 Correct 3 ms 348 KB Output is correct
52 Correct 293 ms 12120 KB Output is correct
53 Correct 319 ms 12116 KB Output is correct
54 Correct 265 ms 12092 KB Output is correct
55 Correct 265 ms 12116 KB Output is correct
56 Correct 308 ms 24744 KB Output is correct
57 Correct 267 ms 24620 KB Output is correct
58 Correct 278 ms 24660 KB Output is correct
59 Correct 286 ms 24632 KB Output is correct
60 Correct 296 ms 24620 KB Output is correct
61 Correct 269 ms 24620 KB Output is correct
62 Correct 267 ms 24660 KB Output is correct
63 Correct 288 ms 24660 KB Output is correct
64 Correct 264 ms 24636 KB Output is correct
65 Correct 279 ms 24660 KB Output is correct
66 Correct 279 ms 24616 KB Output is correct
67 Correct 265 ms 24656 KB Output is correct
68 Correct 278 ms 24740 KB Output is correct