답안 #931923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931923 2024-02-22T14:42:36 Z lovrot Art Exhibition (JOI18_art) C++17
100 / 100
175 ms 23048 KB
#include <cstdio> 
#include <algorithm> 
#include <cstring> 
#include <cmath> 
#include <iostream> 
#include <set> 
#include <queue> 
#include <deque> 
#include <vector> 
#include <random> 
#include <chrono> 

#define X first
#define Y second
#define PB push_back
#define EB emplace_back

using namespace std; 

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MOD = 1e9 + 7; // 998 244 353;
const int N = 5e5 + 10; 
const ll OO = 1e18;

int n, I[N]; 
ll A[N], B[N];

ll prf, xam = -OO, ans; 

int main() {
	scanf("%d", &n); 
	for(int i = 0; i < n; ++i) {
		scanf("%lld%lld\n", A + i, B + i); 
		I[i] = i;
	}
	sort(I, I + n, [](int a, int b) { return A[a] < A[b]; });
	for(int i = 0; i < n; ++i) {
		xam = max(xam, -prf + A[I[i]]);
		prf += B[I[i]];
		ans = max(ans, prf - A[I[i]] + xam);
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
art.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%lld%lld\n", A + i, B + i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4540 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4548 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4540 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4548 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
12 Correct 2 ms 4600 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 2 ms 4696 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4556 KB Output is correct
18 Correct 1 ms 4696 KB Output is correct
19 Correct 1 ms 4696 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4540 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4548 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
12 Correct 2 ms 4600 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 2 ms 4696 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4556 KB Output is correct
18 Correct 1 ms 4696 KB Output is correct
19 Correct 1 ms 4696 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 2 ms 4696 KB Output is correct
28 Correct 4 ms 4664 KB Output is correct
29 Correct 2 ms 4700 KB Output is correct
30 Correct 3 ms 4700 KB Output is correct
31 Correct 2 ms 4700 KB Output is correct
32 Correct 4 ms 4700 KB Output is correct
33 Correct 2 ms 4700 KB Output is correct
34 Correct 2 ms 4700 KB Output is correct
35 Correct 2 ms 4712 KB Output is correct
36 Correct 2 ms 4696 KB Output is correct
37 Correct 2 ms 4700 KB Output is correct
38 Correct 2 ms 4700 KB Output is correct
39 Correct 2 ms 4700 KB Output is correct
40 Correct 2 ms 4664 KB Output is correct
41 Correct 2 ms 4700 KB Output is correct
42 Correct 2 ms 4712 KB Output is correct
43 Correct 2 ms 4700 KB Output is correct
44 Correct 2 ms 4668 KB Output is correct
45 Correct 2 ms 4692 KB Output is correct
46 Correct 2 ms 4700 KB Output is correct
47 Correct 2 ms 4496 KB Output is correct
48 Correct 2 ms 4700 KB Output is correct
49 Correct 2 ms 4700 KB Output is correct
50 Correct 2 ms 4700 KB Output is correct
51 Correct 2 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4540 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4548 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
12 Correct 2 ms 4600 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 2 ms 4696 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4556 KB Output is correct
18 Correct 1 ms 4696 KB Output is correct
19 Correct 1 ms 4696 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 2 ms 4696 KB Output is correct
28 Correct 4 ms 4664 KB Output is correct
29 Correct 2 ms 4700 KB Output is correct
30 Correct 3 ms 4700 KB Output is correct
31 Correct 2 ms 4700 KB Output is correct
32 Correct 4 ms 4700 KB Output is correct
33 Correct 2 ms 4700 KB Output is correct
34 Correct 2 ms 4700 KB Output is correct
35 Correct 2 ms 4712 KB Output is correct
36 Correct 2 ms 4696 KB Output is correct
37 Correct 2 ms 4700 KB Output is correct
38 Correct 2 ms 4700 KB Output is correct
39 Correct 2 ms 4700 KB Output is correct
40 Correct 2 ms 4664 KB Output is correct
41 Correct 2 ms 4700 KB Output is correct
42 Correct 2 ms 4712 KB Output is correct
43 Correct 2 ms 4700 KB Output is correct
44 Correct 2 ms 4668 KB Output is correct
45 Correct 2 ms 4692 KB Output is correct
46 Correct 2 ms 4700 KB Output is correct
47 Correct 2 ms 4496 KB Output is correct
48 Correct 2 ms 4700 KB Output is correct
49 Correct 2 ms 4700 KB Output is correct
50 Correct 2 ms 4700 KB Output is correct
51 Correct 2 ms 4700 KB Output is correct
52 Correct 152 ms 23048 KB Output is correct
53 Correct 151 ms 22608 KB Output is correct
54 Correct 153 ms 22704 KB Output is correct
55 Correct 157 ms 23024 KB Output is correct
56 Correct 150 ms 22680 KB Output is correct
57 Correct 163 ms 22840 KB Output is correct
58 Correct 159 ms 22920 KB Output is correct
59 Correct 150 ms 22628 KB Output is correct
60 Correct 152 ms 22740 KB Output is correct
61 Correct 156 ms 22672 KB Output is correct
62 Correct 175 ms 22712 KB Output is correct
63 Correct 153 ms 22608 KB Output is correct
64 Correct 151 ms 22844 KB Output is correct
65 Correct 150 ms 22832 KB Output is correct
66 Correct 151 ms 22732 KB Output is correct
67 Correct 153 ms 23004 KB Output is correct
68 Correct 151 ms 22892 KB Output is correct