結果

問題 No.733 分身並列コーディング
ユーザー fumofumofunifumofumofuni
提出日時 2022-01-28 01:12:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,258 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 206,492 KB
実行使用メモリ 7,276 KB
最終ジャッジ日時 2023-08-27 04:35:46
合計ジャッジ時間 14,144 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1,479 ms
6,284 KB
testcase_04 TLE -
testcase_05 AC 72 ms
6,488 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 217 ms
6,164 KB
testcase_08 AC 142 ms
6,272 KB
testcase_09 AC 358 ms
4,688 KB
testcase_10 AC 27 ms
4,376 KB
testcase_11 AC 35 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 181 ms
4,384 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 14 ms
4,376 KB
testcase_19 AC 404 ms
4,576 KB
testcase_20 AC 273 ms
4,704 KB
testcase_21 AC 186 ms
4,376 KB
testcase_22 AC 797 ms
6,272 KB
testcase_23 AC 142 ms
4,376 KB
testcase_24 AC 85 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 9 ms
4,380 KB
testcase_28 AC 150 ms
6,276 KB
testcase_29 AC 414 ms
6,284 KB
testcase_30 AC 410 ms
6,216 KB
testcase_31 AC 414 ms
6,164 KB
testcase_32 AC 31 ms
4,376 KB
testcase_33 AC 30 ms
4,380 KB
testcase_34 AC 31 ms
4,380 KB
testcase_35 AC 29 ms
4,380 KB
testcase_36 AC 32 ms
4,380 KB
testcase_37 AC 30 ms
4,380 KB
testcase_38 AC 317 ms
6,332 KB
testcase_39 AC 317 ms
6,356 KB
testcase_40 AC 320 ms
6,188 KB
testcase_41 AC 30 ms
4,376 KB
testcase_42 AC 30 ms
4,376 KB
testcase_43 AC 30 ms
4,376 KB
testcase_44 AC 317 ms
7,276 KB
testcase_45 AC 317 ms
6,144 KB
testcase_46 AC 309 ms
6,232 KB
testcase_47 AC 317 ms
6,488 KB
testcase_48 AC 320 ms
6,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={0,1,-1,0,1,1,-1,-1,0};
const ll dx[9]={1,0,0,-1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 

ll modpow(ll a,ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
      if (n & 1) res = res * a % mod;
      a = a * a % mod;
      n >>= 1;
  }
  return res;
}
ll solve(ll n,vl v,ll m){
    vl idx(1<<n);
    repl(bit,1,1<<n){
        ll p=__builtin_ctz(bit);
        idx[bit]=idx[bit^(1<<p)]+v[p];
    }
  	vl precalc=idx;
    idx.push_back(0);
    sort(all(idx));
    ll ok=1<<n,ng=0;
    while(ok-ng>1){
        ll mod=MOD;
        ll mid=(ok+ng)>>1;
        vl ind(1<<n);
        rep(bit,1<<n){
            if(precalc[bit]<=idx[mid])ind[bit]++;
        }
        rep(i,n){
            rep(bit,1<<n){
                if(bit>>i&1)continue;
                ind[bit|(1<<i)]+=ind[bit];
            }
        }
        ll g=0;
        rep(bit,1<<n){
            ll ret=modpow(ind[bit],m,mod);
            if((n-__builtin_popcount(bit))&1)g-=ret;
            else g+=ret;
          	if(g<0)g+=mod;
          	if(g>=mod)g-=mod;
        }
        if(g)ok=mid;
        else ng=mid;
    }
    return idx[ok];
}
int main(){
    ll t;cin >> t;
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    for(ll m=1;m<=n;m++){
        if(solve(n,v,m)<=t){
            cout << m << endl;return 0;
        }
    }
}   
0