結果

問題 No.1651 Removing Cards
ユーザー reg7777reg7777
提出日時 2021-08-20 22:49:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,015 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 167,104 KB
実行使用メモリ 16,892 KB
最終ジャッジ日時 2024-04-22 05:46:42
合計ジャッジ時間 14,771 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 19 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 570 ms
5,376 KB
testcase_10 AC 912 ms
5,376 KB
testcase_11 AC 1,246 ms
5,376 KB
testcase_12 AC 1,565 ms
5,376 KB
testcase_13 AC 1,882 ms
5,376 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD1 1000000007
#define MOD2 998244353
#define MOD MOD1
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int K,Q;
    cin>>K>>Q;
    for(int i=0;i<Q;i++){
        int N;
        cin>>N;
        vector<int>C;
        while(true){
            C.push_back(N);
            if(N==1)break;
            N-=(N-1)/K+1;
        }
        reverse(rng(C));
        int NN=C.size();
        int now=0;
        for(int i=0;i<NN-1;i++){
            int l=0;
            int r=C[i+1]-C[i]+1;
            int m;
            while(r-l>1){
                m=(r+l)/2;
                if(m*K-m<=now)l=m;
                else r=m;
            }
            now+=l+1;
        }
        cout<<now+1<<endl;
    }

    return 0;
}

//1234567
// 23 56
//  3 5
//    5
0