답안 #255622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255622 2020-08-01T12:55:13 Z tleontest1 Art Exhibition (JOI18_art) C++17
100 / 100
356 ms 60064 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define int long long
#define pb push_back
#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)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 100000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b[li],a[li],k,flag,t,dp[li][4];
int cev;
string s;
PII p[li];
vector<int> v;
 
inline int f(int sira,int al){
	int cevv=-inf;
	if(sira>n){
		if(al==0)return -inf;
		return 0;
	}
	if(~dp[sira][al])return dp[sira][al];
	if(al==0){
		if(sira!=n)
		cevv=max(cevv,f(sira+1,1)+p[sira].fi+p[sira].se);
		cevv=max(cevv,f(n+1,1)+p[sira].se);
		cevv=max(cevv,f(sira+1,0));
	}
	else{
		if(sira!=n)
			cevv=max(cevv,f(sira+1,al)+p[sira].se);
		cevv=max(cevv,f(n+1,al)+p[sira].se-p[sira].fi);
	}
	return dp[sira][al]=cevv;
}
 
main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%lld",&n);
	FOR{
		scanf("%lld %lld",&p[i].fi,&p[i].se);
	}
	sort(p+1,p+n+1);
	printf("%lld\n",f(1,0));
	return 0;
}

Compilation message

art.cpp:58:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
art.cpp: In function 'int main()':
art.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
art.cpp:62:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&p[i].fi,&p[i].se);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16000 KB Output is correct
2 Correct 11 ms 16000 KB Output is correct
3 Correct 9 ms 16000 KB Output is correct
4 Correct 10 ms 16048 KB Output is correct
5 Correct 9 ms 16000 KB Output is correct
6 Correct 9 ms 16000 KB Output is correct
7 Correct 9 ms 16000 KB Output is correct
8 Correct 9 ms 16000 KB Output is correct
9 Correct 9 ms 16000 KB Output is correct
10 Correct 9 ms 16000 KB Output is correct
11 Correct 10 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16000 KB Output is correct
2 Correct 11 ms 16000 KB Output is correct
3 Correct 9 ms 16000 KB Output is correct
4 Correct 10 ms 16048 KB Output is correct
5 Correct 9 ms 16000 KB Output is correct
6 Correct 9 ms 16000 KB Output is correct
7 Correct 9 ms 16000 KB Output is correct
8 Correct 9 ms 16000 KB Output is correct
9 Correct 9 ms 16000 KB Output is correct
10 Correct 9 ms 16000 KB Output is correct
11 Correct 10 ms 16000 KB Output is correct
12 Correct 10 ms 16000 KB Output is correct
13 Correct 9 ms 16000 KB Output is correct
14 Correct 9 ms 16000 KB Output is correct
15 Correct 9 ms 16000 KB Output is correct
16 Correct 9 ms 16000 KB Output is correct
17 Correct 10 ms 16000 KB Output is correct
18 Correct 9 ms 16000 KB Output is correct
19 Correct 9 ms 16000 KB Output is correct
20 Correct 9 ms 16000 KB Output is correct
21 Correct 9 ms 16000 KB Output is correct
22 Correct 9 ms 16000 KB Output is correct
23 Correct 10 ms 16000 KB Output is correct
24 Correct 9 ms 16128 KB Output is correct
25 Correct 13 ms 16000 KB Output is correct
26 Correct 11 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16000 KB Output is correct
2 Correct 11 ms 16000 KB Output is correct
3 Correct 9 ms 16000 KB Output is correct
4 Correct 10 ms 16048 KB Output is correct
5 Correct 9 ms 16000 KB Output is correct
6 Correct 9 ms 16000 KB Output is correct
7 Correct 9 ms 16000 KB Output is correct
8 Correct 9 ms 16000 KB Output is correct
9 Correct 9 ms 16000 KB Output is correct
10 Correct 9 ms 16000 KB Output is correct
11 Correct 10 ms 16000 KB Output is correct
12 Correct 10 ms 16000 KB Output is correct
13 Correct 9 ms 16000 KB Output is correct
14 Correct 9 ms 16000 KB Output is correct
15 Correct 9 ms 16000 KB Output is correct
16 Correct 9 ms 16000 KB Output is correct
17 Correct 10 ms 16000 KB Output is correct
18 Correct 9 ms 16000 KB Output is correct
19 Correct 9 ms 16000 KB Output is correct
20 Correct 9 ms 16000 KB Output is correct
21 Correct 9 ms 16000 KB Output is correct
22 Correct 9 ms 16000 KB Output is correct
23 Correct 10 ms 16000 KB Output is correct
24 Correct 9 ms 16128 KB Output is correct
25 Correct 13 ms 16000 KB Output is correct
26 Correct 11 ms 16000 KB Output is correct
27 Correct 12 ms 16384 KB Output is correct
28 Correct 15 ms 16384 KB Output is correct
29 Correct 13 ms 16384 KB Output is correct
30 Correct 12 ms 16384 KB Output is correct
31 Correct 12 ms 16384 KB Output is correct
32 Correct 12 ms 16384 KB Output is correct
33 Correct 11 ms 16384 KB Output is correct
34 Correct 13 ms 16384 KB Output is correct
35 Correct 11 ms 16384 KB Output is correct
36 Correct 12 ms 16384 KB Output is correct
37 Correct 12 ms 16384 KB Output is correct
38 Correct 12 ms 16384 KB Output is correct
39 Correct 12 ms 16384 KB Output is correct
40 Correct 13 ms 16384 KB Output is correct
41 Correct 11 ms 16384 KB Output is correct
42 Correct 12 ms 16512 KB Output is correct
43 Correct 12 ms 16384 KB Output is correct
44 Correct 12 ms 16384 KB Output is correct
45 Correct 12 ms 16384 KB Output is correct
46 Correct 13 ms 16384 KB Output is correct
47 Correct 12 ms 16384 KB Output is correct
48 Correct 13 ms 16384 KB Output is correct
49 Correct 11 ms 16384 KB Output is correct
50 Correct 12 ms 16384 KB Output is correct
51 Correct 13 ms 16384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16000 KB Output is correct
2 Correct 11 ms 16000 KB Output is correct
3 Correct 9 ms 16000 KB Output is correct
4 Correct 10 ms 16048 KB Output is correct
5 Correct 9 ms 16000 KB Output is correct
6 Correct 9 ms 16000 KB Output is correct
7 Correct 9 ms 16000 KB Output is correct
8 Correct 9 ms 16000 KB Output is correct
9 Correct 9 ms 16000 KB Output is correct
10 Correct 9 ms 16000 KB Output is correct
11 Correct 10 ms 16000 KB Output is correct
12 Correct 10 ms 16000 KB Output is correct
13 Correct 9 ms 16000 KB Output is correct
14 Correct 9 ms 16000 KB Output is correct
15 Correct 9 ms 16000 KB Output is correct
16 Correct 9 ms 16000 KB Output is correct
17 Correct 10 ms 16000 KB Output is correct
18 Correct 9 ms 16000 KB Output is correct
19 Correct 9 ms 16000 KB Output is correct
20 Correct 9 ms 16000 KB Output is correct
21 Correct 9 ms 16000 KB Output is correct
22 Correct 9 ms 16000 KB Output is correct
23 Correct 10 ms 16000 KB Output is correct
24 Correct 9 ms 16128 KB Output is correct
25 Correct 13 ms 16000 KB Output is correct
26 Correct 11 ms 16000 KB Output is correct
27 Correct 12 ms 16384 KB Output is correct
28 Correct 15 ms 16384 KB Output is correct
29 Correct 13 ms 16384 KB Output is correct
30 Correct 12 ms 16384 KB Output is correct
31 Correct 12 ms 16384 KB Output is correct
32 Correct 12 ms 16384 KB Output is correct
33 Correct 11 ms 16384 KB Output is correct
34 Correct 13 ms 16384 KB Output is correct
35 Correct 11 ms 16384 KB Output is correct
36 Correct 12 ms 16384 KB Output is correct
37 Correct 12 ms 16384 KB Output is correct
38 Correct 12 ms 16384 KB Output is correct
39 Correct 12 ms 16384 KB Output is correct
40 Correct 13 ms 16384 KB Output is correct
41 Correct 11 ms 16384 KB Output is correct
42 Correct 12 ms 16512 KB Output is correct
43 Correct 12 ms 16384 KB Output is correct
44 Correct 12 ms 16384 KB Output is correct
45 Correct 12 ms 16384 KB Output is correct
46 Correct 13 ms 16384 KB Output is correct
47 Correct 12 ms 16384 KB Output is correct
48 Correct 13 ms 16384 KB Output is correct
49 Correct 11 ms 16384 KB Output is correct
50 Correct 12 ms 16384 KB Output is correct
51 Correct 13 ms 16384 KB Output is correct
52 Correct 324 ms 59908 KB Output is correct
53 Correct 332 ms 59972 KB Output is correct
54 Correct 324 ms 60024 KB Output is correct
55 Correct 330 ms 60028 KB Output is correct
56 Correct 335 ms 60024 KB Output is correct
57 Correct 322 ms 60028 KB Output is correct
58 Correct 322 ms 59980 KB Output is correct
59 Correct 320 ms 60024 KB Output is correct
60 Correct 329 ms 60064 KB Output is correct
61 Correct 320 ms 59996 KB Output is correct
62 Correct 356 ms 60024 KB Output is correct
63 Correct 335 ms 59896 KB Output is correct
64 Correct 323 ms 59896 KB Output is correct
65 Correct 328 ms 60024 KB Output is correct
66 Correct 321 ms 59932 KB Output is correct
67 Correct 323 ms 60024 KB Output is correct
68 Correct 330 ms 60064 KB Output is correct