Submission #159304

# Submission time Handle Problem Language Result Execution time Memory
159304 2019-10-22T08:43:42 Z AKaan37 Art Exhibition (JOI18_art) C++17
50 / 100
901 ms 204972 KB
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#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 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)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000000000000;
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[5002][5002];
int cev;
string s;
PII p[li];
vector<int> v;

inline int f(int sira,int son){
	int cevv=-inf;
	if(sira>n){
		if(son==0)return -inf;
		return p[son].fi;
	}
	if(sira==n){
		return p[sira].se-p[sira].fi+p[son].fi;
	}
	if(~dp[sira][son])return dp[sira][son];
	if(son==0){
		cevv=max(cevv,f(sira+1,0));
		cevv=max(cevv,f(sira+1,sira)+p[sira].se);
		cevv=max(cevv,f(n+1,sira)+p[sira].se-p[sira].fi);
	}
	else{
		cevv=max(cevv,f(sira+1,son)+p[sira].se);
		cevv=max(cevv,f(n+1,son)+p[sira].se-p[sira].fi);
		cevv=max(cevv,f(sira+1,son));
	}
	return dp[sira][son]=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:67:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
art.cpp: In function 'int main()':
art.cpp:69:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
art.cpp:71: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);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 162 ms 196216 KB Output is correct
2 Correct 159 ms 196132 KB Output is correct
3 Correct 159 ms 196128 KB Output is correct
4 Correct 158 ms 196172 KB Output is correct
5 Correct 160 ms 196220 KB Output is correct
6 Correct 158 ms 196216 KB Output is correct
7 Correct 159 ms 196332 KB Output is correct
8 Correct 160 ms 196216 KB Output is correct
9 Correct 158 ms 196216 KB Output is correct
10 Correct 160 ms 196192 KB Output is correct
11 Correct 159 ms 196188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 196216 KB Output is correct
2 Correct 159 ms 196132 KB Output is correct
3 Correct 159 ms 196128 KB Output is correct
4 Correct 158 ms 196172 KB Output is correct
5 Correct 160 ms 196220 KB Output is correct
6 Correct 158 ms 196216 KB Output is correct
7 Correct 159 ms 196332 KB Output is correct
8 Correct 160 ms 196216 KB Output is correct
9 Correct 158 ms 196216 KB Output is correct
10 Correct 160 ms 196192 KB Output is correct
11 Correct 159 ms 196188 KB Output is correct
12 Correct 171 ms 196176 KB Output is correct
13 Correct 168 ms 196216 KB Output is correct
14 Correct 183 ms 196144 KB Output is correct
15 Correct 193 ms 196376 KB Output is correct
16 Correct 185 ms 196216 KB Output is correct
17 Correct 193 ms 196216 KB Output is correct
18 Correct 166 ms 196200 KB Output is correct
19 Correct 191 ms 196444 KB Output is correct
20 Correct 167 ms 196252 KB Output is correct
21 Correct 167 ms 196216 KB Output is correct
22 Correct 167 ms 196216 KB Output is correct
23 Correct 168 ms 196296 KB Output is correct
24 Correct 167 ms 196216 KB Output is correct
25 Correct 168 ms 196216 KB Output is correct
26 Correct 186 ms 196208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 196216 KB Output is correct
2 Correct 159 ms 196132 KB Output is correct
3 Correct 159 ms 196128 KB Output is correct
4 Correct 158 ms 196172 KB Output is correct
5 Correct 160 ms 196220 KB Output is correct
6 Correct 158 ms 196216 KB Output is correct
7 Correct 159 ms 196332 KB Output is correct
8 Correct 160 ms 196216 KB Output is correct
9 Correct 158 ms 196216 KB Output is correct
10 Correct 160 ms 196192 KB Output is correct
11 Correct 159 ms 196188 KB Output is correct
12 Correct 171 ms 196176 KB Output is correct
13 Correct 168 ms 196216 KB Output is correct
14 Correct 183 ms 196144 KB Output is correct
15 Correct 193 ms 196376 KB Output is correct
16 Correct 185 ms 196216 KB Output is correct
17 Correct 193 ms 196216 KB Output is correct
18 Correct 166 ms 196200 KB Output is correct
19 Correct 191 ms 196444 KB Output is correct
20 Correct 167 ms 196252 KB Output is correct
21 Correct 167 ms 196216 KB Output is correct
22 Correct 167 ms 196216 KB Output is correct
23 Correct 168 ms 196296 KB Output is correct
24 Correct 167 ms 196216 KB Output is correct
25 Correct 168 ms 196216 KB Output is correct
26 Correct 186 ms 196208 KB Output is correct
27 Correct 660 ms 196668 KB Output is correct
28 Correct 631 ms 196856 KB Output is correct
29 Correct 628 ms 196736 KB Output is correct
30 Correct 693 ms 196728 KB Output is correct
31 Correct 679 ms 196772 KB Output is correct
32 Correct 638 ms 196740 KB Output is correct
33 Correct 649 ms 196748 KB Output is correct
34 Correct 627 ms 196684 KB Output is correct
35 Correct 620 ms 196780 KB Output is correct
36 Correct 633 ms 196728 KB Output is correct
37 Correct 620 ms 196728 KB Output is correct
38 Correct 618 ms 196856 KB Output is correct
39 Correct 630 ms 196776 KB Output is correct
40 Correct 631 ms 196856 KB Output is correct
41 Correct 628 ms 196768 KB Output is correct
42 Correct 650 ms 196856 KB Output is correct
43 Correct 625 ms 196776 KB Output is correct
44 Correct 703 ms 196732 KB Output is correct
45 Correct 637 ms 196828 KB Output is correct
46 Correct 637 ms 196856 KB Output is correct
47 Correct 626 ms 196736 KB Output is correct
48 Correct 620 ms 196844 KB Output is correct
49 Correct 629 ms 196768 KB Output is correct
50 Correct 632 ms 196696 KB Output is correct
51 Correct 621 ms 196728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 196216 KB Output is correct
2 Correct 159 ms 196132 KB Output is correct
3 Correct 159 ms 196128 KB Output is correct
4 Correct 158 ms 196172 KB Output is correct
5 Correct 160 ms 196220 KB Output is correct
6 Correct 158 ms 196216 KB Output is correct
7 Correct 159 ms 196332 KB Output is correct
8 Correct 160 ms 196216 KB Output is correct
9 Correct 158 ms 196216 KB Output is correct
10 Correct 160 ms 196192 KB Output is correct
11 Correct 159 ms 196188 KB Output is correct
12 Correct 171 ms 196176 KB Output is correct
13 Correct 168 ms 196216 KB Output is correct
14 Correct 183 ms 196144 KB Output is correct
15 Correct 193 ms 196376 KB Output is correct
16 Correct 185 ms 196216 KB Output is correct
17 Correct 193 ms 196216 KB Output is correct
18 Correct 166 ms 196200 KB Output is correct
19 Correct 191 ms 196444 KB Output is correct
20 Correct 167 ms 196252 KB Output is correct
21 Correct 167 ms 196216 KB Output is correct
22 Correct 167 ms 196216 KB Output is correct
23 Correct 168 ms 196296 KB Output is correct
24 Correct 167 ms 196216 KB Output is correct
25 Correct 168 ms 196216 KB Output is correct
26 Correct 186 ms 196208 KB Output is correct
27 Correct 660 ms 196668 KB Output is correct
28 Correct 631 ms 196856 KB Output is correct
29 Correct 628 ms 196736 KB Output is correct
30 Correct 693 ms 196728 KB Output is correct
31 Correct 679 ms 196772 KB Output is correct
32 Correct 638 ms 196740 KB Output is correct
33 Correct 649 ms 196748 KB Output is correct
34 Correct 627 ms 196684 KB Output is correct
35 Correct 620 ms 196780 KB Output is correct
36 Correct 633 ms 196728 KB Output is correct
37 Correct 620 ms 196728 KB Output is correct
38 Correct 618 ms 196856 KB Output is correct
39 Correct 630 ms 196776 KB Output is correct
40 Correct 631 ms 196856 KB Output is correct
41 Correct 628 ms 196768 KB Output is correct
42 Correct 650 ms 196856 KB Output is correct
43 Correct 625 ms 196776 KB Output is correct
44 Correct 703 ms 196732 KB Output is correct
45 Correct 637 ms 196828 KB Output is correct
46 Correct 637 ms 196856 KB Output is correct
47 Correct 626 ms 196736 KB Output is correct
48 Correct 620 ms 196844 KB Output is correct
49 Correct 629 ms 196768 KB Output is correct
50 Correct 632 ms 196696 KB Output is correct
51 Correct 621 ms 196728 KB Output is correct
52 Incorrect 901 ms 204972 KB Output isn't correct
53 Halted 0 ms 0 KB -