답안 #1094340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094340 2024-09-29T10:58:30 Z blacktulip Art Exhibition (JOI18_art) C++17
100 / 100
165 ms 60052 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long lo; 

#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
#define _ << " " <<

const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,a[li],k,flag,t,b[li],dp[li][2];
int cev;
string s;
vector<int> v;
pair<int,int> p[li];

inline int f(int i,int al){
	int cevap=-1000000000000000000;
	if(i==n+2){
		return 0;
	}
	if(i==n+1){
		return -1000000000000000000;
	}
	if(~dp[i][al])return dp[i][al];
	a[i]=p[i].fi;
	b[i]=p[i].se;
	cevap=max(cevap,f(i+1,al));
	cevap=max(cevap,f(n+2,1)+b[i]-a[i]+(al==0?a[i]:0));
	cevap=max(cevap,f(i+1,1)+b[i]+(al==0?a[i]:0));
	return dp[i][al]=cevap;
}

int32_t main(void){
	fio();
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++){
		cin>>p[i].fi>>p[i].se;
	}
	sort(p+1,p+n+1);
	cout<<f(1,0)<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8284 KB Output is correct
3 Correct 3 ms 8284 KB Output is correct
4 Correct 3 ms 8284 KB Output is correct
5 Correct 3 ms 8308 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 3 ms 8284 KB Output is correct
10 Correct 3 ms 8284 KB Output is correct
11 Correct 4 ms 8284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8284 KB Output is correct
3 Correct 3 ms 8284 KB Output is correct
4 Correct 3 ms 8284 KB Output is correct
5 Correct 3 ms 8308 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 3 ms 8284 KB Output is correct
10 Correct 3 ms 8284 KB Output is correct
11 Correct 4 ms 8284 KB Output is correct
12 Correct 3 ms 8284 KB Output is correct
13 Correct 4 ms 8256 KB Output is correct
14 Correct 4 ms 8284 KB Output is correct
15 Correct 3 ms 8284 KB Output is correct
16 Correct 3 ms 8284 KB Output is correct
17 Correct 3 ms 8284 KB Output is correct
18 Correct 4 ms 8284 KB Output is correct
19 Correct 3 ms 8284 KB Output is correct
20 Correct 3 ms 8280 KB Output is correct
21 Correct 3 ms 8284 KB Output is correct
22 Correct 3 ms 8284 KB Output is correct
23 Correct 3 ms 8208 KB Output is correct
24 Correct 3 ms 8284 KB Output is correct
25 Correct 5 ms 8280 KB Output is correct
26 Correct 3 ms 8284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8284 KB Output is correct
3 Correct 3 ms 8284 KB Output is correct
4 Correct 3 ms 8284 KB Output is correct
5 Correct 3 ms 8308 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 3 ms 8284 KB Output is correct
10 Correct 3 ms 8284 KB Output is correct
11 Correct 4 ms 8284 KB Output is correct
12 Correct 3 ms 8284 KB Output is correct
13 Correct 4 ms 8256 KB Output is correct
14 Correct 4 ms 8284 KB Output is correct
15 Correct 3 ms 8284 KB Output is correct
16 Correct 3 ms 8284 KB Output is correct
17 Correct 3 ms 8284 KB Output is correct
18 Correct 4 ms 8284 KB Output is correct
19 Correct 3 ms 8284 KB Output is correct
20 Correct 3 ms 8280 KB Output is correct
21 Correct 3 ms 8284 KB Output is correct
22 Correct 3 ms 8284 KB Output is correct
23 Correct 3 ms 8208 KB Output is correct
24 Correct 3 ms 8284 KB Output is correct
25 Correct 5 ms 8280 KB Output is correct
26 Correct 3 ms 8284 KB Output is correct
27 Correct 5 ms 8796 KB Output is correct
28 Correct 5 ms 8796 KB Output is correct
29 Correct 5 ms 8796 KB Output is correct
30 Correct 5 ms 8676 KB Output is correct
31 Correct 5 ms 8796 KB Output is correct
32 Correct 5 ms 8796 KB Output is correct
33 Correct 5 ms 8796 KB Output is correct
34 Correct 7 ms 8796 KB Output is correct
35 Correct 5 ms 8756 KB Output is correct
36 Correct 5 ms 8796 KB Output is correct
37 Correct 5 ms 8796 KB Output is correct
38 Correct 5 ms 8796 KB Output is correct
39 Correct 5 ms 8600 KB Output is correct
40 Correct 5 ms 8796 KB Output is correct
41 Correct 4 ms 8796 KB Output is correct
42 Correct 5 ms 8800 KB Output is correct
43 Correct 5 ms 8704 KB Output is correct
44 Correct 5 ms 8800 KB Output is correct
45 Correct 5 ms 8796 KB Output is correct
46 Correct 5 ms 8800 KB Output is correct
47 Correct 5 ms 8648 KB Output is correct
48 Correct 5 ms 8792 KB Output is correct
49 Correct 4 ms 8796 KB Output is correct
50 Correct 4 ms 8796 KB Output is correct
51 Correct 4 ms 9048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8280 KB Output is correct
2 Correct 3 ms 8284 KB Output is correct
3 Correct 3 ms 8284 KB Output is correct
4 Correct 3 ms 8284 KB Output is correct
5 Correct 3 ms 8308 KB Output is correct
6 Correct 3 ms 8280 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 3 ms 8284 KB Output is correct
9 Correct 3 ms 8284 KB Output is correct
10 Correct 3 ms 8284 KB Output is correct
11 Correct 4 ms 8284 KB Output is correct
12 Correct 3 ms 8284 KB Output is correct
13 Correct 4 ms 8256 KB Output is correct
14 Correct 4 ms 8284 KB Output is correct
15 Correct 3 ms 8284 KB Output is correct
16 Correct 3 ms 8284 KB Output is correct
17 Correct 3 ms 8284 KB Output is correct
18 Correct 4 ms 8284 KB Output is correct
19 Correct 3 ms 8284 KB Output is correct
20 Correct 3 ms 8280 KB Output is correct
21 Correct 3 ms 8284 KB Output is correct
22 Correct 3 ms 8284 KB Output is correct
23 Correct 3 ms 8208 KB Output is correct
24 Correct 3 ms 8284 KB Output is correct
25 Correct 5 ms 8280 KB Output is correct
26 Correct 3 ms 8284 KB Output is correct
27 Correct 5 ms 8796 KB Output is correct
28 Correct 5 ms 8796 KB Output is correct
29 Correct 5 ms 8796 KB Output is correct
30 Correct 5 ms 8676 KB Output is correct
31 Correct 5 ms 8796 KB Output is correct
32 Correct 5 ms 8796 KB Output is correct
33 Correct 5 ms 8796 KB Output is correct
34 Correct 7 ms 8796 KB Output is correct
35 Correct 5 ms 8756 KB Output is correct
36 Correct 5 ms 8796 KB Output is correct
37 Correct 5 ms 8796 KB Output is correct
38 Correct 5 ms 8796 KB Output is correct
39 Correct 5 ms 8600 KB Output is correct
40 Correct 5 ms 8796 KB Output is correct
41 Correct 4 ms 8796 KB Output is correct
42 Correct 5 ms 8800 KB Output is correct
43 Correct 5 ms 8704 KB Output is correct
44 Correct 5 ms 8800 KB Output is correct
45 Correct 5 ms 8796 KB Output is correct
46 Correct 5 ms 8800 KB Output is correct
47 Correct 5 ms 8648 KB Output is correct
48 Correct 5 ms 8792 KB Output is correct
49 Correct 4 ms 8796 KB Output is correct
50 Correct 4 ms 8796 KB Output is correct
51 Correct 4 ms 9048 KB Output is correct
52 Correct 151 ms 59988 KB Output is correct
53 Correct 156 ms 59836 KB Output is correct
54 Correct 148 ms 59904 KB Output is correct
55 Correct 147 ms 59988 KB Output is correct
56 Correct 151 ms 59864 KB Output is correct
57 Correct 153 ms 59956 KB Output is correct
58 Correct 142 ms 59984 KB Output is correct
59 Correct 136 ms 59932 KB Output is correct
60 Correct 150 ms 59988 KB Output is correct
61 Correct 142 ms 59660 KB Output is correct
62 Correct 141 ms 59988 KB Output is correct
63 Correct 143 ms 59836 KB Output is correct
64 Correct 144 ms 60044 KB Output is correct
65 Correct 165 ms 59912 KB Output is correct
66 Correct 147 ms 59824 KB Output is correct
67 Correct 146 ms 59984 KB Output is correct
68 Correct 142 ms 60052 KB Output is correct