結果

問題 No.1651 Removing Cards
ユーザー pockynypockyny
提出日時 2021-08-20 23:00:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 1,283 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 82,652 KB
実行使用メモリ 7,628 KB
最終ジャッジ日時 2024-04-22 06:56:24
合計ジャッジ時間 8,874 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 194 ms
5,376 KB
testcase_10 AC 189 ms
5,376 KB
testcase_11 AC 181 ms
5,376 KB
testcase_12 AC 181 ms
5,376 KB
testcase_13 AC 182 ms
5,376 KB
testcase_14 AC 192 ms
5,376 KB
testcase_15 AC 208 ms
7,504 KB
testcase_16 AC 203 ms
7,500 KB
testcase_17 AC 211 ms
7,496 KB
testcase_18 AC 231 ms
7,500 KB
testcase_19 AC 222 ms
7,628 KB
testcase_20 AC 208 ms
7,496 KB
testcase_21 AC 220 ms
7,388 KB
testcase_22 AC 202 ms
7,500 KB
testcase_23 AC 195 ms
5,376 KB
testcase_24 AC 151 ms
5,376 KB
testcase_25 AC 171 ms
7,500 KB
testcase_26 AC 178 ms
7,544 KB
testcase_27 AC 210 ms
7,504 KB
testcase_28 AC 214 ms
7,372 KB
testcase_29 AC 203 ms
7,500 KB
testcase_30 AC 210 ms
7,500 KB
testcase_31 AC 224 ms
7,372 KB
testcase_32 AC 177 ms
5,376 KB
testcase_33 AC 173 ms
5,376 KB
testcase_34 AC 172 ms
5,376 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