Submission #47966

# Submission time Handle Problem Language Result Execution time Memory
47966 2018-05-09T09:17:45 Z WA_TLE Bali Sculptures (APIO15_sculpture) C++14
100 / 100
75 ms 2668 KB
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
//17:53~
int main(void){
	int n,i,j,A,B;cin>>n>>A>>B;
	vector<llint>y(n);
	vector<llint>wa(n+1);
	for(i=0;i<n;i++){cin>>y[i];}
	for(i=1;i<=n;i++){wa[i]=y[i-1]+wa[i-1];}
	//上のビットから立つかどうかを決める
	//するとこの区間をとってよいかどうかが決まる
	//A=1ならcanまでの最小値を求めていけばいい
	//A>1ならbitsetを持たせる
	//2^41にならない
	if(A==1){
		llint ans=(1LL<<41)-1;
		vector<int>sai(n+1);
		for(int h=40;h>=0;h--){
			ans-=(1LL<<h);
			for(i=0;i<=n;i++){sai[i]=mod;}
			sai[0]=0;
			for(i=1;i<=n;i++){
				for(j=0;j<i;j++){
					if(((wa[i]-wa[j])|ans)==ans){
						mineq(sai[i],sai[j]+1);
					}
				}
			}
			//cout<<sai[n]<<endl;
			ans+=(1LL<<h);
			if(sai[n]<=B){ans-=(1LL<<h);}
		}
		cout<<ans<<endl;
	}else{
		llint ans=(1LL<<41)-1;
		vector<bitset<101>>sai(n+1);
		bitset<101>kara;
		for(int h=40;h>=0;h--){
			ans-=(1LL<<h);
			for(i=0;i<=n;i++){sai[i]=kara;}
			sai[0][0]=1;
			for(i=1;i<=n;i++){
				for(j=0;j<i;j++){
					if(((wa[i]-wa[j])|ans)==ans){
						sai[i]|=(sai[j]<<1);
					}
				}
			}
			ans+=(1LL<<h);
			for(i=A;i<=B;i++){
				if(sai[n][i]){ans-=(1LL<<h);break;}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 668 KB Output is correct
5 Correct 2 ms 856 KB Output is correct
6 Correct 2 ms 856 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 856 KB Output is correct
9 Correct 2 ms 856 KB Output is correct
10 Correct 2 ms 872 KB Output is correct
11 Correct 2 ms 1140 KB Output is correct
12 Correct 2 ms 1140 KB Output is correct
13 Correct 2 ms 1140 KB Output is correct
14 Correct 2 ms 1140 KB Output is correct
15 Correct 2 ms 1140 KB Output is correct
16 Correct 2 ms 1140 KB Output is correct
17 Correct 2 ms 1140 KB Output is correct
18 Correct 2 ms 1140 KB Output is correct
19 Correct 2 ms 1140 KB Output is correct
20 Correct 2 ms 1140 KB Output is correct
21 Correct 2 ms 1140 KB Output is correct
22 Correct 2 ms 1140 KB Output is correct
23 Correct 2 ms 1140 KB Output is correct
24 Correct 2 ms 1140 KB Output is correct
25 Correct 2 ms 1140 KB Output is correct
26 Correct 2 ms 1140 KB Output is correct
27 Correct 2 ms 1140 KB Output is correct
28 Correct 2 ms 1140 KB Output is correct
29 Correct 2 ms 1140 KB Output is correct
30 Correct 2 ms 1140 KB Output is correct
31 Correct 2 ms 1140 KB Output is correct
32 Correct 2 ms 1140 KB Output is correct
33 Correct 2 ms 1140 KB Output is correct
34 Correct 2 ms 1140 KB Output is correct
35 Correct 2 ms 1140 KB Output is correct
36 Correct 2 ms 1140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1140 KB Output is correct
2 Correct 2 ms 1140 KB Output is correct
3 Correct 2 ms 1140 KB Output is correct
4 Correct 2 ms 1140 KB Output is correct
5 Correct 2 ms 1140 KB Output is correct
6 Correct 2 ms 1140 KB Output is correct
7 Correct 2 ms 1140 KB Output is correct
8 Correct 2 ms 1140 KB Output is correct
9 Correct 2 ms 1140 KB Output is correct
10 Correct 2 ms 1140 KB Output is correct
11 Correct 2 ms 1140 KB Output is correct
12 Correct 2 ms 1140 KB Output is correct
13 Correct 2 ms 1140 KB Output is correct
14 Correct 2 ms 1140 KB Output is correct
15 Correct 2 ms 1140 KB Output is correct
16 Correct 2 ms 1140 KB Output is correct
17 Correct 2 ms 1140 KB Output is correct
18 Correct 2 ms 1140 KB Output is correct
19 Correct 2 ms 1140 KB Output is correct
20 Correct 2 ms 1140 KB Output is correct
21 Correct 2 ms 1140 KB Output is correct
22 Correct 2 ms 1140 KB Output is correct
23 Correct 2 ms 1140 KB Output is correct
24 Correct 2 ms 1140 KB Output is correct
25 Correct 2 ms 1140 KB Output is correct
26 Correct 2 ms 1140 KB Output is correct
27 Correct 2 ms 1140 KB Output is correct
28 Correct 2 ms 1140 KB Output is correct
29 Correct 2 ms 1140 KB Output is correct
30 Correct 2 ms 1140 KB Output is correct
31 Correct 2 ms 1140 KB Output is correct
32 Correct 2 ms 1140 KB Output is correct
33 Correct 2 ms 1140 KB Output is correct
34 Correct 2 ms 1140 KB Output is correct
35 Correct 2 ms 1260 KB Output is correct
36 Correct 2 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1260 KB Output is correct
2 Correct 2 ms 1276 KB Output is correct
3 Correct 2 ms 1276 KB Output is correct
4 Correct 2 ms 1276 KB Output is correct
5 Correct 2 ms 1400 KB Output is correct
6 Correct 2 ms 1400 KB Output is correct
7 Correct 2 ms 1400 KB Output is correct
8 Correct 2 ms 1400 KB Output is correct
9 Correct 2 ms 1400 KB Output is correct
10 Correct 2 ms 1400 KB Output is correct
11 Correct 2 ms 1400 KB Output is correct
12 Correct 2 ms 1400 KB Output is correct
13 Correct 2 ms 1400 KB Output is correct
14 Correct 2 ms 1480 KB Output is correct
15 Correct 2 ms 1480 KB Output is correct
16 Correct 2 ms 1480 KB Output is correct
17 Correct 2 ms 1480 KB Output is correct
18 Correct 2 ms 1480 KB Output is correct
19 Correct 2 ms 1480 KB Output is correct
20 Correct 2 ms 1480 KB Output is correct
21 Correct 2 ms 1480 KB Output is correct
22 Correct 2 ms 1480 KB Output is correct
23 Correct 2 ms 1480 KB Output is correct
24 Correct 2 ms 1480 KB Output is correct
25 Correct 2 ms 1480 KB Output is correct
26 Correct 2 ms 1480 KB Output is correct
27 Correct 2 ms 1480 KB Output is correct
28 Correct 2 ms 1480 KB Output is correct
29 Correct 2 ms 1480 KB Output is correct
30 Correct 2 ms 1480 KB Output is correct
31 Correct 2 ms 1480 KB Output is correct
32 Correct 2 ms 1480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1480 KB Output is correct
2 Correct 2 ms 1480 KB Output is correct
3 Correct 2 ms 1480 KB Output is correct
4 Correct 2 ms 1480 KB Output is correct
5 Correct 2 ms 1480 KB Output is correct
6 Correct 2 ms 1480 KB Output is correct
7 Correct 2 ms 1480 KB Output is correct
8 Correct 2 ms 1480 KB Output is correct
9 Correct 2 ms 1588 KB Output is correct
10 Correct 2 ms 1588 KB Output is correct
11 Correct 2 ms 1588 KB Output is correct
12 Correct 2 ms 1608 KB Output is correct
13 Correct 2 ms 1608 KB Output is correct
14 Correct 2 ms 1648 KB Output is correct
15 Correct 2 ms 1648 KB Output is correct
16 Correct 2 ms 1648 KB Output is correct
17 Correct 2 ms 1648 KB Output is correct
18 Correct 2 ms 1648 KB Output is correct
19 Correct 2 ms 1648 KB Output is correct
20 Correct 2 ms 1648 KB Output is correct
21 Correct 2 ms 1648 KB Output is correct
22 Correct 2 ms 1648 KB Output is correct
23 Correct 2 ms 1648 KB Output is correct
24 Correct 2 ms 1648 KB Output is correct
25 Correct 2 ms 1648 KB Output is correct
26 Correct 2 ms 1648 KB Output is correct
27 Correct 2 ms 1648 KB Output is correct
28 Correct 2 ms 1648 KB Output is correct
29 Correct 2 ms 1648 KB Output is correct
30 Correct 2 ms 1648 KB Output is correct
31 Correct 2 ms 1648 KB Output is correct
32 Correct 2 ms 1648 KB Output is correct
33 Correct 2 ms 1648 KB Output is correct
34 Correct 2 ms 1648 KB Output is correct
35 Correct 2 ms 1732 KB Output is correct
36 Correct 2 ms 1732 KB Output is correct
37 Correct 2 ms 1752 KB Output is correct
38 Correct 2 ms 1752 KB Output is correct
39 Correct 2 ms 1752 KB Output is correct
40 Correct 2 ms 1752 KB Output is correct
41 Correct 2 ms 1752 KB Output is correct
42 Correct 2 ms 1752 KB Output is correct
43 Correct 2 ms 1752 KB Output is correct
44 Correct 2 ms 1752 KB Output is correct
45 Correct 2 ms 1752 KB Output is correct
46 Correct 2 ms 1752 KB Output is correct
47 Correct 2 ms 1752 KB Output is correct
48 Correct 2 ms 1752 KB Output is correct
49 Correct 2 ms 1752 KB Output is correct
50 Correct 2 ms 1752 KB Output is correct
51 Correct 2 ms 1752 KB Output is correct
52 Correct 2 ms 1812 KB Output is correct
53 Correct 2 ms 1812 KB Output is correct
54 Correct 2 ms 1812 KB Output is correct
55 Correct 2 ms 1812 KB Output is correct
56 Correct 2 ms 1812 KB Output is correct
57 Correct 2 ms 1812 KB Output is correct
58 Correct 2 ms 1812 KB Output is correct
59 Correct 2 ms 1812 KB Output is correct
60 Correct 2 ms 1860 KB Output is correct
61 Correct 2 ms 1860 KB Output is correct
62 Correct 2 ms 1860 KB Output is correct
63 Correct 2 ms 1860 KB Output is correct
64 Correct 2 ms 1876 KB Output is correct
65 Correct 2 ms 1876 KB Output is correct
66 Correct 2 ms 1884 KB Output is correct
67 Correct 2 ms 1884 KB Output is correct
68 Correct 2 ms 1884 KB Output is correct
69 Correct 2 ms 1884 KB Output is correct
70 Correct 2 ms 1884 KB Output is correct
71 Correct 2 ms 1884 KB Output is correct
72 Correct 2 ms 1884 KB Output is correct
73 Correct 2 ms 1884 KB Output is correct
74 Correct 2 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 2 ms 1944 KB Output is correct
4 Correct 2 ms 1944 KB Output is correct
5 Correct 2 ms 1944 KB Output is correct
6 Correct 2 ms 1944 KB Output is correct
7 Correct 1 ms 1944 KB Output is correct
8 Correct 2 ms 1944 KB Output is correct
9 Correct 2 ms 1944 KB Output is correct
10 Correct 2 ms 1944 KB Output is correct
11 Correct 2 ms 1944 KB Output is correct
12 Correct 2 ms 1944 KB Output is correct
13 Correct 2 ms 1944 KB Output is correct
14 Correct 2 ms 1944 KB Output is correct
15 Correct 2 ms 1944 KB Output is correct
16 Correct 2 ms 1944 KB Output is correct
17 Correct 2 ms 1944 KB Output is correct
18 Correct 2 ms 1944 KB Output is correct
19 Correct 2 ms 1944 KB Output is correct
20 Correct 2 ms 1944 KB Output is correct
21 Correct 2 ms 1944 KB Output is correct
22 Correct 2 ms 1944 KB Output is correct
23 Correct 2 ms 1944 KB Output is correct
24 Correct 2 ms 2052 KB Output is correct
25 Correct 2 ms 2052 KB Output is correct
26 Correct 2 ms 2052 KB Output is correct
27 Correct 2 ms 2052 KB Output is correct
28 Correct 2 ms 2052 KB Output is correct
29 Correct 2 ms 2052 KB Output is correct
30 Correct 2 ms 2052 KB Output is correct
31 Correct 2 ms 2052 KB Output is correct
32 Correct 2 ms 2052 KB Output is correct
33 Correct 2 ms 2052 KB Output is correct
34 Correct 2 ms 2052 KB Output is correct
35 Correct 3 ms 2052 KB Output is correct
36 Correct 2 ms 2052 KB Output is correct
37 Correct 2 ms 2052 KB Output is correct
38 Correct 2 ms 2144 KB Output is correct
39 Correct 2 ms 2144 KB Output is correct
40 Correct 2 ms 2144 KB Output is correct
41 Correct 2 ms 2144 KB Output is correct
42 Correct 2 ms 2288 KB Output is correct
43 Correct 2 ms 2288 KB Output is correct
44 Correct 2 ms 2288 KB Output is correct
45 Correct 2 ms 2288 KB Output is correct
46 Correct 2 ms 2288 KB Output is correct
47 Correct 2 ms 2288 KB Output is correct
48 Correct 2 ms 2288 KB Output is correct
49 Correct 2 ms 2288 KB Output is correct
50 Correct 2 ms 2288 KB Output is correct
51 Correct 3 ms 2288 KB Output is correct
52 Correct 10 ms 2288 KB Output is correct
53 Correct 12 ms 2288 KB Output is correct
54 Correct 22 ms 2288 KB Output is correct
55 Correct 20 ms 2288 KB Output is correct
56 Correct 69 ms 2304 KB Output is correct
57 Correct 69 ms 2368 KB Output is correct
58 Correct 70 ms 2368 KB Output is correct
59 Correct 69 ms 2432 KB Output is correct
60 Correct 73 ms 2432 KB Output is correct
61 Correct 2 ms 2432 KB Output is correct
62 Correct 12 ms 2432 KB Output is correct
63 Correct 23 ms 2440 KB Output is correct
64 Correct 20 ms 2452 KB Output is correct
65 Correct 37 ms 2480 KB Output is correct
66 Correct 54 ms 2624 KB Output is correct
67 Correct 75 ms 2624 KB Output is correct
68 Correct 74 ms 2668 KB Output is correct
69 Correct 68 ms 2668 KB Output is correct