답안 #49553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49553 2018-05-31T07:45:36 Z hamzqq9 Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 11792 KB
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define cc pair<char,char>
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 1000000005
#define M 10000002
#define N 2005
#define LOG 59
#define magic 100
#define KOK 250
#define EPS 0.0025
#define pw(x) ((1ll)<<(x))
#define PI 3.1415926535
using namespace std;

int n,a,b;
int ar[N],mn[N];
bool dp[105][105];
vector<int> v[N];

bool ok(ll val) {

	for(int i=1;i<=n;i++) {

		v[i-1].clear();

		mn[i]=inf;

		ll sum=0;

		for(int j=i-1;j>=0;j--) {

			sum+=ar[j+1];

			if((sum|val)==val) {
			
				v[j].pb(i);
				
				umin(mn[i],mn[j]+1);

			}

		}

	}

	if(a==1) {

		return (mn[n]<=b);

	}

	memset(dp,0,sizeof(dp));

	dp[0][0]=1;

	for(int l=1;l<=n;l++) {

		for(int i=0;i<=n;i++) {

			if(dp[l-1][i]) {

				for(int ind:v[i]) {

					dp[l][ind]=1;

				}

			}

		}

	}

	for(int i=a;i<=b;i++) if(dp[i][n]) return true;

	return false;

}

int main() {
 
 	#if 0
	freopen("input.txt","r",stdin);
 	#endif

	scanf("%d %d %d",&n,&a,&b);

	for(int i=1;i<=n;i++) {

		scanf("%d",&ar[i]);

	}

	ll full=pw(60)-1;

	for(int i=LOG;i>=0;i--) {

		full-=pw(i);

		if(!ok(full)) full+=pw(i);

	}

	printf("%lld",full);

}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:114:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&a,&b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:118:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&ar[i]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 3 ms 532 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 2 ms 740 KB Output is correct
14 Correct 2 ms 740 KB Output is correct
15 Correct 2 ms 740 KB Output is correct
16 Correct 2 ms 740 KB Output is correct
17 Correct 3 ms 740 KB Output is correct
18 Correct 2 ms 740 KB Output is correct
19 Correct 2 ms 740 KB Output is correct
20 Correct 2 ms 740 KB Output is correct
21 Correct 2 ms 740 KB Output is correct
22 Correct 2 ms 740 KB Output is correct
23 Correct 2 ms 740 KB Output is correct
24 Correct 2 ms 740 KB Output is correct
25 Correct 2 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 2 ms 740 KB Output is correct
28 Correct 2 ms 740 KB Output is correct
29 Correct 2 ms 740 KB Output is correct
30 Correct 3 ms 740 KB Output is correct
31 Correct 2 ms 740 KB Output is correct
32 Correct 2 ms 740 KB Output is correct
33 Correct 3 ms 740 KB Output is correct
34 Correct 2 ms 740 KB Output is correct
35 Correct 2 ms 812 KB Output is correct
36 Correct 2 ms 812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 812 KB Output is correct
2 Correct 2 ms 812 KB Output is correct
3 Correct 2 ms 812 KB Output is correct
4 Correct 3 ms 812 KB Output is correct
5 Correct 2 ms 812 KB Output is correct
6 Correct 3 ms 812 KB Output is correct
7 Correct 2 ms 812 KB Output is correct
8 Correct 2 ms 812 KB Output is correct
9 Correct 2 ms 812 KB Output is correct
10 Correct 2 ms 812 KB Output is correct
11 Correct 3 ms 812 KB Output is correct
12 Correct 2 ms 812 KB Output is correct
13 Correct 2 ms 812 KB Output is correct
14 Correct 2 ms 812 KB Output is correct
15 Correct 2 ms 812 KB Output is correct
16 Correct 2 ms 812 KB Output is correct
17 Correct 2 ms 812 KB Output is correct
18 Correct 2 ms 812 KB Output is correct
19 Correct 21 ms 812 KB Output is correct
20 Correct 2 ms 812 KB Output is correct
21 Correct 2 ms 812 KB Output is correct
22 Correct 2 ms 812 KB Output is correct
23 Correct 2 ms 812 KB Output is correct
24 Correct 3 ms 812 KB Output is correct
25 Correct 2 ms 812 KB Output is correct
26 Correct 2 ms 812 KB Output is correct
27 Correct 3 ms 812 KB Output is correct
28 Correct 2 ms 812 KB Output is correct
29 Correct 2 ms 812 KB Output is correct
30 Correct 3 ms 812 KB Output is correct
31 Correct 2 ms 812 KB Output is correct
32 Correct 2 ms 812 KB Output is correct
33 Correct 3 ms 812 KB Output is correct
34 Correct 3 ms 812 KB Output is correct
35 Correct 3 ms 812 KB Output is correct
36 Correct 2 ms 812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 812 KB Output is correct
2 Correct 2 ms 812 KB Output is correct
3 Correct 2 ms 812 KB Output is correct
4 Correct 2 ms 812 KB Output is correct
5 Correct 3 ms 812 KB Output is correct
6 Correct 3 ms 812 KB Output is correct
7 Correct 2 ms 812 KB Output is correct
8 Correct 2 ms 812 KB Output is correct
9 Correct 2 ms 812 KB Output is correct
10 Correct 2 ms 812 KB Output is correct
11 Correct 3 ms 812 KB Output is correct
12 Correct 2 ms 812 KB Output is correct
13 Correct 2 ms 812 KB Output is correct
14 Correct 2 ms 812 KB Output is correct
15 Correct 2 ms 812 KB Output is correct
16 Correct 2 ms 812 KB Output is correct
17 Correct 3 ms 812 KB Output is correct
18 Correct 2 ms 812 KB Output is correct
19 Correct 3 ms 812 KB Output is correct
20 Correct 2 ms 812 KB Output is correct
21 Correct 3 ms 812 KB Output is correct
22 Correct 3 ms 812 KB Output is correct
23 Correct 2 ms 812 KB Output is correct
24 Correct 4 ms 812 KB Output is correct
25 Correct 3 ms 812 KB Output is correct
26 Correct 3 ms 812 KB Output is correct
27 Correct 3 ms 812 KB Output is correct
28 Correct 3 ms 812 KB Output is correct
29 Correct 5 ms 812 KB Output is correct
30 Correct 4 ms 812 KB Output is correct
31 Correct 4 ms 812 KB Output is correct
32 Correct 3 ms 812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 812 KB Output is correct
2 Correct 2 ms 812 KB Output is correct
3 Correct 2 ms 812 KB Output is correct
4 Correct 2 ms 812 KB Output is correct
5 Correct 2 ms 812 KB Output is correct
6 Correct 2 ms 812 KB Output is correct
7 Correct 2 ms 812 KB Output is correct
8 Correct 2 ms 812 KB Output is correct
9 Correct 3 ms 812 KB Output is correct
10 Correct 2 ms 812 KB Output is correct
11 Correct 2 ms 812 KB Output is correct
12 Correct 2 ms 812 KB Output is correct
13 Correct 2 ms 812 KB Output is correct
14 Correct 2 ms 812 KB Output is correct
15 Correct 2 ms 812 KB Output is correct
16 Correct 2 ms 812 KB Output is correct
17 Correct 2 ms 812 KB Output is correct
18 Correct 2 ms 812 KB Output is correct
19 Correct 2 ms 812 KB Output is correct
20 Correct 2 ms 812 KB Output is correct
21 Correct 3 ms 812 KB Output is correct
22 Correct 2 ms 812 KB Output is correct
23 Correct 2 ms 812 KB Output is correct
24 Correct 2 ms 812 KB Output is correct
25 Correct 2 ms 812 KB Output is correct
26 Correct 3 ms 812 KB Output is correct
27 Correct 2 ms 812 KB Output is correct
28 Correct 2 ms 812 KB Output is correct
29 Correct 2 ms 812 KB Output is correct
30 Correct 2 ms 812 KB Output is correct
31 Correct 3 ms 812 KB Output is correct
32 Correct 2 ms 812 KB Output is correct
33 Correct 2 ms 812 KB Output is correct
34 Correct 2 ms 812 KB Output is correct
35 Correct 2 ms 812 KB Output is correct
36 Correct 2 ms 812 KB Output is correct
37 Correct 2 ms 812 KB Output is correct
38 Correct 2 ms 812 KB Output is correct
39 Correct 3 ms 812 KB Output is correct
40 Correct 2 ms 812 KB Output is correct
41 Correct 3 ms 812 KB Output is correct
42 Correct 3 ms 812 KB Output is correct
43 Correct 3 ms 904 KB Output is correct
44 Correct 3 ms 904 KB Output is correct
45 Correct 3 ms 904 KB Output is correct
46 Correct 3 ms 904 KB Output is correct
47 Correct 3 ms 904 KB Output is correct
48 Correct 3 ms 904 KB Output is correct
49 Correct 3 ms 904 KB Output is correct
50 Correct 3 ms 904 KB Output is correct
51 Correct 5 ms 904 KB Output is correct
52 Correct 4 ms 904 KB Output is correct
53 Correct 4 ms 904 KB Output is correct
54 Correct 4 ms 904 KB Output is correct
55 Correct 3 ms 904 KB Output is correct
56 Correct 3 ms 904 KB Output is correct
57 Correct 3 ms 904 KB Output is correct
58 Correct 3 ms 924 KB Output is correct
59 Correct 4 ms 924 KB Output is correct
60 Correct 3 ms 924 KB Output is correct
61 Correct 4 ms 928 KB Output is correct
62 Correct 4 ms 932 KB Output is correct
63 Correct 4 ms 932 KB Output is correct
64 Correct 10 ms 932 KB Output is correct
65 Correct 4 ms 932 KB Output is correct
66 Correct 5 ms 932 KB Output is correct
67 Correct 5 ms 932 KB Output is correct
68 Correct 7 ms 948 KB Output is correct
69 Correct 8 ms 948 KB Output is correct
70 Correct 7 ms 948 KB Output is correct
71 Correct 8 ms 948 KB Output is correct
72 Correct 8 ms 948 KB Output is correct
73 Correct 8 ms 948 KB Output is correct
74 Correct 8 ms 948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 948 KB Output is correct
2 Correct 2 ms 948 KB Output is correct
3 Correct 2 ms 948 KB Output is correct
4 Correct 2 ms 948 KB Output is correct
5 Correct 2 ms 948 KB Output is correct
6 Correct 2 ms 948 KB Output is correct
7 Correct 3 ms 948 KB Output is correct
8 Correct 2 ms 948 KB Output is correct
9 Correct 2 ms 948 KB Output is correct
10 Correct 2 ms 948 KB Output is correct
11 Correct 3 ms 948 KB Output is correct
12 Correct 2 ms 948 KB Output is correct
13 Correct 2 ms 948 KB Output is correct
14 Correct 3 ms 948 KB Output is correct
15 Correct 2 ms 948 KB Output is correct
16 Correct 2 ms 948 KB Output is correct
17 Correct 2 ms 948 KB Output is correct
18 Correct 2 ms 948 KB Output is correct
19 Correct 3 ms 948 KB Output is correct
20 Correct 2 ms 948 KB Output is correct
21 Correct 2 ms 952 KB Output is correct
22 Correct 2 ms 956 KB Output is correct
23 Correct 3 ms 960 KB Output is correct
24 Correct 3 ms 964 KB Output is correct
25 Correct 2 ms 968 KB Output is correct
26 Correct 3 ms 972 KB Output is correct
27 Correct 3 ms 976 KB Output is correct
28 Correct 2 ms 980 KB Output is correct
29 Correct 3 ms 984 KB Output is correct
30 Correct 3 ms 984 KB Output is correct
31 Correct 2 ms 992 KB Output is correct
32 Correct 2 ms 996 KB Output is correct
33 Correct 3 ms 1000 KB Output is correct
34 Correct 3 ms 1072 KB Output is correct
35 Correct 2 ms 1072 KB Output is correct
36 Correct 3 ms 1072 KB Output is correct
37 Correct 3 ms 1072 KB Output is correct
38 Correct 3 ms 1072 KB Output is correct
39 Correct 3 ms 1072 KB Output is correct
40 Correct 3 ms 1072 KB Output is correct
41 Correct 3 ms 1076 KB Output is correct
42 Correct 3 ms 1120 KB Output is correct
43 Correct 3 ms 1120 KB Output is correct
44 Correct 3 ms 1120 KB Output is correct
45 Correct 3 ms 1120 KB Output is correct
46 Correct 3 ms 1120 KB Output is correct
47 Correct 3 ms 1120 KB Output is correct
48 Correct 3 ms 1120 KB Output is correct
49 Correct 3 ms 1120 KB Output is correct
50 Correct 3 ms 1196 KB Output is correct
51 Correct 3 ms 1196 KB Output is correct
52 Correct 47 ms 1976 KB Output is correct
53 Correct 123 ms 2752 KB Output is correct
54 Correct 220 ms 3848 KB Output is correct
55 Correct 225 ms 3848 KB Output is correct
56 Execution timed out 1089 ms 11792 KB Time limit exceeded
57 Halted 0 ms 0 KB -