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

Submission #3658052

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;

ll maxd(vector<ll> &v, ll maxa, ll k) {
ll a = 1;
while(maxa >= a) {
a *= 2;
}
a /= 2;
while (a > 0) {
a /= 2;
ll 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() {
ll N, K;
cin >> N >> K;
ll s[1002][1002];
for (ll i = 0; i != N; ++i) {
for (ll j = 0; j <= N; ++j) {
s[i][j] = 0;
}
}
vector<ll> vs;
for (ll i = 0; i != N; ++i) {
ll a;
cin >> a;
for (ll 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);
// for (auto i : vs) {
// 	cout << i << endl;
// }
// cout << endl;
}
cout << out << endl;
}
```

#### Submission Info

Submission Time 2018-11-24 21:31:50+0900 B - Sum AND Subarrays taku0728 C++14 (GCC 5.4.1) 0 1345 Byte TLE 2656 ms 14320 KB

#### Judge Result

Set Name All
Score / Max Score 0 / 400
Status
 AC × 10 TLE × 11
Set Name Test Cases
All 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 TLE 2655 ms 14192 KB
n-large-k-small2 TLE 2656 ms 13168 KB
n-large-k-small3 TLE 2656 ms 14320 KB
n-large-k-small4 TLE 2656 ms 13936 KB
n-large-k-small5 TLE 2656 ms 13168 KB
n-medium-1 TLE 2656 ms 8052 KB
n-medium-2 TLE 2656 ms 13808 KB
n-medium-3 AC 8 ms 2944 KB
n-medium-4 AC 102 ms 3580 KB
n-medium-5 AC 20 ms 3072 KB
n-medium-6 TLE 2656 ms 12912 KB
n-medium-7 TLE 2656 ms 8052 KB
n-medium-k-small-1 AC 14 ms 1152 KB
n-medium-k-small-2 AC 1105 ms 6008 KB
n-small-1 AC 2 ms 2432 KB
n-small-2 AC 3 ms 2560 KB
n-small-3 AC 2 ms 2304 KB
nk-large-1 TLE 2656 ms 12912 KB
nk-large-2 TLE 2656 ms 13808 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB