結果

問題 No.1651 Removing Cards
ユーザー pockynypockyny
提出日時 2021-08-20 23:00:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,283 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 8,980 KB
最終ジャッジ日時 2023-08-04 09:09:52
合計ジャッジ時間 8,442 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 176 ms
4,376 KB
testcase_10 AC 176 ms
4,376 KB
testcase_11 AC 182 ms
4,380 KB
testcase_12 AC 186 ms
4,380 KB
testcase_13 AC 184 ms
4,380 KB
testcase_14 AC 185 ms
4,376 KB
testcase_15 AC 217 ms
8,120 KB
testcase_16 AC 216 ms
8,120 KB
testcase_17 AC 210 ms
7,692 KB
testcase_18 AC 202 ms
7,632 KB
testcase_19 AC 197 ms
8,980 KB
testcase_20 AC 206 ms
7,424 KB
testcase_21 AC 198 ms
8,416 KB
testcase_22 AC 193 ms
7,332 KB
testcase_23 AC 191 ms
4,376 KB
testcase_24 AC 148 ms
4,376 KB
testcase_25 AC 169 ms
7,592 KB
testcase_26 AC 172 ms
8,208 KB
testcase_27 AC 204 ms
7,928 KB
testcase_28 AC 205 ms
8,056 KB
testcase_29 AC 204 ms
7,900 KB
testcase_30 AC 194 ms
8,256 KB
testcase_31 AC 197 ms
7,684 KB
testcase_32 AC 162 ms
4,376 KB
testcase_33 AC 170 ms
4,380 KB
testcase_34 AC 173 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
vector<int> solve(int n,int k){
    vector<int> v(n);
    int i,j = 0;
    while(true){
        j++;
        vector<int> u;
        for(i=0;i<n;i++){
            if(!v[i]) u.push_back(i);
        }
        if(u.size()==0) break;
        for(i=0;i<u.size();i+=k){
            v[u[i]] = j;
        }
    }
    return v;
}

typedef long long ll;
ll inf = 1000000000000000000;
int main(){
    /*int i,n; cin >> n;
    for(i=1;i<=n;i++){
        vector<int> v = solve(i,4);
        //cout << "num = " << i << ", ";
        int mx = -1,ret = -1;
        for(int j=0;j<v.size();j++){
            if(mx<v[j]){
                mx = max(mx,v[j]); ret = j;
            }
        }
        cout << (ret + 1) << " ";
        /*for(int x:v) cout << x << " ";
        cout << endl;
    }*/
    int i,k,q; cin >> k >> q;
    vector<ll> v;
    v.push_back(1);
    while(v.back()<inf){
        //cout << v.size() << " " << v.back() << endl;
        ll x = v.back();
        ll p = (x + (k - 2))/(k - 1);
        v.push_back(x + p);
    }
    //cout << v.size() << endl;
    for(i=0;i<q;i++){
        ll n; cin >> n;
        auto it = upper_bound(v.begin(),v.end(),n);
        it--;
        cout << (*it) << endl;
    }
}
0