Submission #41418

# Submission time Handle Problem Language Result Execution time Memory
41418 2018-02-17T07:57:21 Z Nurlykhan Bali Sculptures (APIO15_sculpture) C++14
50 / 100
221 ms 748 KB
#include <bits/stdc++.h>

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 2e3 + 10;
const int M = (int) 2000 + 100;
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

const int nx[4] = {0, 0, -1, 1};
const int ny[4] = {1, -1, 0, 0};

int n, L, R;
ll a[N];
int dp[N];

ll get_sum(int l, int r) {
  return a[r] - a[l - 1];
}

void upd(int &x, int y) {
  x = min(x, y);
}

bool check(ll x, ll y, int i) {
  x |= (1LL << i) - 1;
  x = ~x;
  if ((x & y) > 0) {
    return false;
  }
  return true;
}

bool can(int id, ll val) {
  dp[0] = 0;
  for (int r = 1; r <= n; r++) {
    dp[r] = R + 1;
    for (int l = 1; l <= r; l++) {
      if (check(val, get_sum(l, r), id)) 
        dp[r] = min(dp[r], dp[l - 1] + 1);
    }
  }
  return dp[n] <= R;
}

int main() {
  #define fn "teams"
  #ifdef witch
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif  
  cin >> n >> L >> R;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  ll val = 0;
  for (int bits = 60; bits >= 0; bits--) {
    if (!can(bits, val)) {
      val |= (1LL << bits);
    }
  }
  cout << val;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 1 ms 484 KB Output is correct
4 Correct 1 ms 484 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Incorrect 1 ms 596 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Incorrect 1 ms 620 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 620 KB Output is correct
7 Correct 1 ms 620 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 1 ms 624 KB Output is correct
15 Correct 1 ms 624 KB Output is correct
16 Correct 1 ms 624 KB Output is correct
17 Correct 1 ms 624 KB Output is correct
18 Correct 2 ms 624 KB Output is correct
19 Correct 2 ms 624 KB Output is correct
20 Correct 2 ms 624 KB Output is correct
21 Correct 2 ms 624 KB Output is correct
22 Correct 2 ms 624 KB Output is correct
23 Correct 2 ms 624 KB Output is correct
24 Correct 2 ms 624 KB Output is correct
25 Correct 2 ms 624 KB Output is correct
26 Correct 2 ms 624 KB Output is correct
27 Correct 2 ms 624 KB Output is correct
28 Correct 3 ms 624 KB Output is correct
29 Correct 3 ms 624 KB Output is correct
30 Correct 3 ms 624 KB Output is correct
31 Correct 2 ms 624 KB Output is correct
32 Correct 2 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 624 KB Output is correct
2 Correct 2 ms 624 KB Output is correct
3 Correct 2 ms 624 KB Output is correct
4 Correct 2 ms 624 KB Output is correct
5 Correct 1 ms 624 KB Output is correct
6 Correct 1 ms 624 KB Output is correct
7 Correct 1 ms 624 KB Output is correct
8 Correct 1 ms 624 KB Output is correct
9 Correct 1 ms 624 KB Output is correct
10 Correct 2 ms 624 KB Output is correct
11 Correct 1 ms 624 KB Output is correct
12 Correct 2 ms 624 KB Output is correct
13 Correct 1 ms 624 KB Output is correct
14 Correct 2 ms 624 KB Output is correct
15 Incorrect 1 ms 624 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 624 KB Output is correct
2 Correct 1 ms 624 KB Output is correct
3 Correct 2 ms 624 KB Output is correct
4 Correct 2 ms 624 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Correct 2 ms 624 KB Output is correct
8 Correct 1 ms 624 KB Output is correct
9 Correct 2 ms 624 KB Output is correct
10 Correct 1 ms 624 KB Output is correct
11 Correct 1 ms 624 KB Output is correct
12 Correct 1 ms 624 KB Output is correct
13 Correct 1 ms 624 KB Output is correct
14 Correct 1 ms 624 KB Output is correct
15 Correct 1 ms 624 KB Output is correct
16 Correct 1 ms 624 KB Output is correct
17 Correct 1 ms 624 KB Output is correct
18 Correct 2 ms 624 KB Output is correct
19 Correct 1 ms 624 KB Output is correct
20 Correct 1 ms 624 KB Output is correct
21 Correct 2 ms 624 KB Output is correct
22 Correct 1 ms 624 KB Output is correct
23 Correct 1 ms 624 KB Output is correct
24 Correct 1 ms 624 KB Output is correct
25 Correct 1 ms 624 KB Output is correct
26 Correct 2 ms 624 KB Output is correct
27 Correct 1 ms 624 KB Output is correct
28 Correct 2 ms 624 KB Output is correct
29 Correct 2 ms 624 KB Output is correct
30 Correct 2 ms 624 KB Output is correct
31 Correct 2 ms 624 KB Output is correct
32 Correct 2 ms 624 KB Output is correct
33 Correct 2 ms 624 KB Output is correct
34 Correct 2 ms 624 KB Output is correct
35 Correct 2 ms 624 KB Output is correct
36 Correct 2 ms 624 KB Output is correct
37 Correct 2 ms 624 KB Output is correct
38 Correct 2 ms 624 KB Output is correct
39 Correct 2 ms 624 KB Output is correct
40 Correct 2 ms 624 KB Output is correct
41 Correct 2 ms 624 KB Output is correct
42 Correct 2 ms 624 KB Output is correct
43 Correct 1 ms 624 KB Output is correct
44 Correct 2 ms 624 KB Output is correct
45 Correct 2 ms 624 KB Output is correct
46 Correct 2 ms 624 KB Output is correct
47 Correct 2 ms 624 KB Output is correct
48 Correct 2 ms 624 KB Output is correct
49 Correct 2 ms 624 KB Output is correct
50 Correct 2 ms 624 KB Output is correct
51 Correct 2 ms 624 KB Output is correct
52 Correct 21 ms 624 KB Output is correct
53 Correct 32 ms 624 KB Output is correct
54 Correct 57 ms 624 KB Output is correct
55 Correct 57 ms 624 KB Output is correct
56 Correct 214 ms 624 KB Output is correct
57 Correct 218 ms 628 KB Output is correct
58 Correct 211 ms 632 KB Output is correct
59 Correct 212 ms 632 KB Output is correct
60 Correct 215 ms 632 KB Output is correct
61 Correct 2 ms 632 KB Output is correct
62 Correct 34 ms 632 KB Output is correct
63 Correct 60 ms 748 KB Output is correct
64 Correct 55 ms 748 KB Output is correct
65 Correct 106 ms 748 KB Output is correct
66 Correct 166 ms 748 KB Output is correct
67 Correct 221 ms 748 KB Output is correct
68 Correct 218 ms 748 KB Output is correct
69 Correct 212 ms 748 KB Output is correct