Submission #17636938


Source Code Expand

Copy
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

bool check(vector<int>& sum, int n, int m) {
  int all = (1 << n) - 1;
  for (int S = 0; S < (1 << n); ++S) {
    int T = all ^ S;
    if (sum[all] - sum[T] < __builtin_popcount(S) * m) return false;
  }
  return true;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int B = 5e6;
  int low = n * m, high = B;
  vector<int> sum(1 << n);
  vector<int> b(B);
  while (low != high) {
    int mid = (low + high) / 2;
    fill(sum.begin(), sum.end(), 0);
    fill(b.begin(), b.begin() + mid, 0);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < mid; j += 2 * a[i]) {
        for (int k = 0; k < a[i] && j + k < mid; ++k) b[j + k] |= 1 << i;
      }
    }
    for (int i = 0; i < mid; ++i) sum[b[i]]++;
    trace(sum);
    for (int k = 0; k < n; ++k) {
      for (int S = 0; S < (1 << n); ++S) {
        if ((S >> k) & 1) sum[S] += sum[S ^ (1 << k)];
      }
    }
    if (!check(sum, n, m)) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  cout << high << '\n';
  return 0;
}

Submission Info

Submission Time
Task E - Medals
User cuiaoxiang
Language C++ (Clang 10.0.0)
Score 0
Code Size 3586 Byte
Status TLE
Exec Time 3317 ms
Memory 24560 KB

Compile Error

./Main.cpp:78:11: warning: unused variable 'INF' [-Wunused-const-variable]
const int INF = 1 << 29;
          ^
./Main.cpp:79:11: warning: unused variable 'MOD' [-Wunused-const-variable]
const int MOD = 1e9 + 7;
          ^
2 warnings generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 3
AC × 25
TLE × 15
Set Name Test Cases
Sample 00_sample_01, 00_sample_02, 00_sample_03
All 00_sample_01, 00_sample_02, 00_sample_03, 10_small_01, 10_small_02, 10_small_03, 10_small_04, 10_small_05, 10_small_06, 10_small_07, 10_small_08, 10_small_09, 10_small_10, 20_random_01, 20_random_02, 20_random_03, 20_random_04, 20_random_05, 20_random_06, 20_random_07, 20_random_08, 20_random_09, 20_random_10, 30_max_01, 30_max_02, 30_max_03, 30_max_04, 30_max_05, 31_max_01, 31_max_02, big_00, big_01, big_02, big_03, big_04, sml_00, sml_01, sml_02, sml_03, sml_04
Case Name Status Exec Time Memory
00_sample_01 AC 48 ms 22432 KB
00_sample_02 AC 123 ms 22308 KB
00_sample_03 AC 38 ms 22248 KB
10_small_01 AC 33 ms 22404 KB
10_small_02 AC 33 ms 22252 KB
10_small_03 AC 28 ms 22252 KB
10_small_04 AC 35 ms 22180 KB
10_small_05 AC 30 ms 22288 KB
10_small_06 AC 35 ms 22308 KB
10_small_07 AC 38 ms 22400 KB
10_small_08 AC 43 ms 22372 KB
10_small_09 AC 31 ms 22320 KB
10_small_10 AC 40 ms 22232 KB
20_random_01 TLE 3314 ms 23768 KB
20_random_02 AC 1190 ms 22308 KB
20_random_03 TLE 3313 ms 23700 KB
20_random_04 AC 43 ms 22232 KB
20_random_05 TLE 3314 ms 24536 KB
20_random_06 AC 56 ms 22404 KB
20_random_07 AC 97 ms 22400 KB
20_random_08 AC 41 ms 22312 KB
20_random_09 AC 35 ms 22112 KB
20_random_10 AC 1240 ms 22256 KB
30_max_01 TLE 3313 ms 23852 KB
30_max_02 TLE 3314 ms 24540 KB
30_max_03 TLE 3314 ms 24452 KB
30_max_04 TLE 3313 ms 23892 KB
30_max_05 TLE 3317 ms 24412 KB
31_max_01 TLE 3313 ms 24412 KB
31_max_02 TLE 3313 ms 24444 KB
big_00 TLE 3314 ms 24544 KB
big_01 TLE 3314 ms 24540 KB
big_02 TLE 3314 ms 24540 KB
big_03 TLE 3314 ms 24536 KB
big_04 TLE 3313 ms 24560 KB
sml_00 AC 72 ms 22264 KB
sml_01 AC 46 ms 22248 KB
sml_02 AC 70 ms 22304 KB
sml_03 AC 67 ms 22288 KB
sml_04 AC 62 ms 22308 KB