Contest Duration: ~ (local time) (120 minutes)

Submission #3656556

Source Code Expand

Copy
```#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <chrono>
using namespace std;
using ll = long long;

int maxd(vector<ll> &v, ll maxa, int k) {
ll a = 1;
while(maxa >= a) {
a *= 2;
}
a /= 2;
while (a > 0) {
a /= 2;
int count = 0;
for (auto i : v) {
if ((i & a) == a) {
++count;
}
if (count == k){
return a;
}
}
}
return a;
}

void cut(vector<ll> &v, ll a) {
auto itr = v.begin();
while (itr != v.end())
{
if((*itr & a) < a)
{
itr = v.erase(itr);
}
else
{
itr++;
}
}
}

int main() {
int N, K;
cin >> N >> K;
ll s[1002][1002];
for (int j = 0; j <= N; ++j) {
s[0][j] = 0;
}
vector<ll> vs;
for (int i = 0; i != N; ++i) {
int a;
cin >> a;
for (int j = 0; j <= i; ++j) {
s[i + 1][j] = s[i][j] + a;
vs.push_back(s[i + 1][j]);
}
}
sort(begin(vs), end(vs), greater<ll>());
ll out = 0;
ll a = 1e14;
while (a > 0) {
a = maxd(vs, a, K);
out += a;
cut(vs, a);
}
cout << out << endl;
}
```

#### Submission Info

Submission Time 2018-11-24 20:56:51+0900 B - Sum AND Subarrays taku0728 C++14 (GCC 5.4.1) 0 1228 Byte WA 46 ms 12912 KB

#### Judge Result

Set Name Score / Max Score Test Cases
All 0 / 400 n-large-k-small1, n-large-k-small2, n-large-k-small3, n-large-k-small4, n-large-k-small5, n-medium-1, n-medium-2, n-medium-3, n-medium-4, n-medium-5, n-medium-6, n-medium-7, n-medium-k-small-1, n-medium-k-small-2, n-small-1, n-small-2, n-small-3, nk-large-1, nk-large-2, sample_01, sample_02
Case Name Status Exec Time Memory
n-large-k-small1 38 ms 12400 KB
n-large-k-small2 38 ms 11756 KB
n-large-k-small3 38 ms 12912 KB
n-large-k-small4 38 ms 11500 KB
n-large-k-small5 38 ms 12140 KB
n-medium-1 19 ms 7540 KB
n-medium-2 31 ms 12528 KB
n-medium-3 2 ms 1024 KB
n-medium-4 5 ms 3964 KB
n-medium-5 3 ms 3072 KB
n-medium-6 34 ms 11504 KB
n-medium-7 46 ms 9200 KB
n-medium-k-small-1 2 ms 2816 KB
n-medium-k-small-2 9 ms 5880 KB
n-small-1 2 ms 2432 KB
n-small-2 3 ms 640 KB
n-small-3 1 ms 384 KB
nk-large-1 39 ms 11500 KB
nk-large-2 38 ms 11500 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB