Submission #41424

# Submission time Handle Problem Language Result Execution time Memory
41424 2018-02-17T08:12:09 Z cmaster Bali Sculptures (APIO15_sculpture) C++14
0 / 100
6 ms 700 KB
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
#define F first
#define S second
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, l, r, a[MAXN];
int dp[MAXN];
ll pref[MAXN];

inline bool check(ll lim, ll mid, ll MOD, ll tmp) {
	dp[0] = 0;
	int L = 0;
	rep(i, 1, n) {
		ll cur = 0ll;
		dp[i] = n+n;
		while(pref[i] - pref[L] >= lim) L++;
		rep(j, L+1, i) {
			cur = pref[i] - pref[j-1];
			if(cur % MOD < mid && (cur & tmp) == 0ll) {
				updmin(dp[i], dp[j-1]+1);
				break;
			}
		}
		// cerr << dp[i] << ' ';
	}
	return dp[n] <= r;
}

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n >> l >> r;
	rep(i, 1, n) cin >> a[i];
	rep(i, 1, n) pref[i] = pref[i-1]+a[i];
	int last = 42, fr = 42;
	ll res = 0ll;
	ll just = 0ll;
	per(bit, 40, 0) {
		ll lim = (1ll << fr*1ll);
		if(last == 42) lim = (1ll << bit);
		if(!check(lim, (1ll<<bit*1ll), (1ll << last*1ll), just)) {
			if(fr == 42) fr = bit+1;
			res |= (1ll << bit*1ll);
			last = bit;
		} else just |= (1ll << bit*1ll);
	}
	cout << res << nxtl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 540 KB Output is correct
4 Correct 1 ms 556 KB Output is correct
5 Correct 1 ms 556 KB Output is correct
6 Incorrect 1 ms 700 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 700 KB Output is correct
2 Correct 1 ms 700 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 700 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Incorrect 1 ms 700 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 700 KB Output is correct
2 Correct 1 ms 700 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 700 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Incorrect 1 ms 700 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 700 KB Output is correct
2 Correct 1 ms 700 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 700 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Incorrect 1 ms 700 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 700 KB Output is correct
2 Correct 1 ms 700 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 700 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Incorrect 1 ms 700 KB Output isn't correct
7 Halted 0 ms 0 KB -