Submission #17638981


Source Code Expand

//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \###################\
//   \###################\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.
 
#ifdef local
#include <bits/extc++.h>
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(args...) qqbx(#args, args)
using ost = std::ostream;
#define DESTL(STL, BEG, END, OUT) \
    template <typename ...T> ost& operator<<(ost &O, std::STL<T...> v) { int f=0; for(auto x: v) O << (f++ ? ", " : BEG) << OUT; return O << END; }
DESTL(deque, "[", "]", x); DESTL(vector, "[", "]", x);
DESTL(set, "{", "}", x); DESTL(multiset, "{", "}", x); DESTL(unordered_set, "{", "}", x);
DESTL(map , "{", "}", x.first << ":" << x.second); DESTL(unordered_map , "{", "}", x.first << ":" << x.second);
template <typename U, typename V> ost& operator<<(ost &O, std::pair<U,V> p) { return O << '(' << p.first << ',' << p.second << ')'; }
template <typename T, size_t N> ost& operator<<(ost &O, std::array<T,N> a) { int f=0; for(T x: a) O << (f++ ? ", " : "[") << x; return O << "]"; }
template <typename T, size_t ...I> ost& prtuple(ost &O, T t, std::index_sequence<I...>) { return (..., (O << (I ? ", " : "(") << std::get<I>(t))), O << ")"; }
template <typename ...T> ost& operator<<(ost &O, std::tuple<T...> t) { return prtuple(O, t, std::make_index_sequence<sizeof...(T)>()); }
template <typename ...T> void qqbx(const char *s, T ...args) {
    int cnt = sizeof...(T);
    (std::cerr << "\033[1;32m(" << s << ") = (" , ... , (std::cerr << args << (--cnt ? ", " : ")\033[0m\n")));
}
#else
#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include <bits/extc++.h>
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define get_pos(v,x) int(lower_bound(begin(v),end(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define pb emplace_back
#define ff first
#define ss second
#define mem(v,x) memset(v,x,sizeof v)
 
using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
template <typename T> using max_heap = std::priority_queue<T,vector<T>,less<T> >;
template <typename T> using min_heap = std::priority_queue<T,vector<T>,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
constexpr ld PI = acos(-1), eps = 1e-7;
constexpr ll N = 100025, INF = 1e18, MOD = 998244353, K = 19, inf = 1e7;
constexpr inline ll cdiv(ll x, ll m) { return x/m + ((x<0 ^ m>0) && (x%m)); } // ceiling divide
constexpr inline ll modpow(ll e,ll p,ll m=MOD) { ll r=1; for(e%=m;p;p>>=1,e=e*e%m) if(p&1) r=r*e%m; return r; }

int n, k, a[K];
int mask[N*K*2];
bool ok(int lim) {
    vector<int> cnt(1<<n);
    for(int t = 0; t < lim; t++) cnt[mask[t]] += 1;
    for(int i = 0; i < n; i++) for(int s = 0; s < (1<<n); s++) if(s >> i & 1) cnt[s] += cnt[s ^ (1<<i)];
    /* for(int s = 0, U = (1<<n)-1; s < n; s++) cnt[s] += cnt[U ^ s]; */
    /* for(int i = 0; i < n; i++) for(int s = 0; s < (1<<n); s++) if(s >> i & 1) cnt[s] -= cnt[s ^ (1<<i)]; */
    /* vector<int> ss(1<<n); */
    /* for(int s = 0; s < (1<<n); s++) { */
    /*     for(int t = 0; t < (1<<n); t++) { */
    /*         if(s & t) { */
    /*             ss[s] += cnt[t]; */
    /*         } */
    /*     } */
    /* } */
    /* cnt=ss; */
    for(int s = 0, U = (1<<n)-1; s < (1<<n); s++) {
        int C = lim - cnt[U ^ s];
        if(C < __builtin_popcount(s) * k) return false;
    }
    return true;
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < N*K*2; i++) for(int j = 0; j < n; j++) if(i % (a[j] * 2) < a[j]) mask[i] |= 1 << j;
    /* debug(ok(10)); */
    /* return 0; */
    int x = 0;
    for(int s = 1<<21; s; s>>=1) if(x+s < N*K*2 && !ok(x+s)) x += s;
    ++x;
    cout << x << '\n';
}

Submission Info

Submission Time
Task E - Medals
User bingxuan9112
Language C++ (GCC 9.2.1)
Score 700
Code Size 4281 Byte
Status AC
Exec Time 444 ms
Memory 19484 KiB

Compile Error

./Main.cpp:9:1: warning: multi-line comment [-Wcomment]
    9 | //  \###################\
      | ^
./Main.cpp:35: warning: ignoring #pragma loop_opt  [-Wunknown-pragmas]
   35 | #pragma loop_opt(on)
      | 
./Main.cpp: In function ‘constexpr ll cdiv(ll, ll)’:
./Main.cpp:60:56: warning: suggest parentheses around comparison in operand of ‘^’ [-Wparentheses]
   60 | constexpr inline ll cdiv(ll x, ll m) { return x/m + ((x<0 ^ m>0) && (x%m)); } // ceiling divide
      |                                                       ~^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 40
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 64 ms 18360 KiB
00_sample_02 AC 135 ms 18392 KiB
00_sample_03 AC 51 ms 17804 KiB
10_small_01 AC 48 ms 18360 KiB
10_small_02 AC 46 ms 18360 KiB
10_small_03 AC 47 ms 18316 KiB
10_small_04 AC 44 ms 18432 KiB
10_small_05 AC 47 ms 18432 KiB
10_small_06 AC 48 ms 18328 KiB
10_small_07 AC 68 ms 18320 KiB
10_small_08 AC 81 ms 18328 KiB
10_small_09 AC 58 ms 18460 KiB
10_small_10 AC 68 ms 18396 KiB
20_random_01 AC 243 ms 18680 KiB
20_random_02 AC 202 ms 18500 KiB
20_random_03 AC 240 ms 18584 KiB
20_random_04 AC 49 ms 14892 KiB
20_random_05 AC 386 ms 19484 KiB
20_random_06 AC 79 ms 18008 KiB
20_random_07 AC 127 ms 18384 KiB
20_random_08 AC 64 ms 16320 KiB
20_random_09 AC 39 ms 11456 KiB
20_random_10 AC 211 ms 18396 KiB
30_max_01 AC 369 ms 11592 KiB
30_max_02 AC 423 ms 11948 KiB
30_max_03 AC 419 ms 12124 KiB
30_max_04 AC 332 ms 11508 KiB
30_max_05 AC 443 ms 12116 KiB
31_max_01 AC 443 ms 12104 KiB
31_max_02 AC 444 ms 11932 KiB
big_00 AC 346 ms 18644 KiB
big_01 AC 355 ms 19408 KiB
big_02 AC 375 ms 18504 KiB
big_03 AC 389 ms 18752 KiB
big_04 AC 353 ms 19280 KiB
sml_00 AC 87 ms 18380 KiB
sml_01 AC 82 ms 18384 KiB
sml_02 AC 87 ms 18432 KiB
sml_03 AC 84 ms 18424 KiB
sml_04 AC 82 ms 18324 KiB