結果
問題 |
No.1651 Removing Cards
|
ユーザー |
![]() |
提出日時 | 2021-08-20 22:49:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,015 bytes |
コンパイル時間 | 1,544 ms |
コンパイル使用メモリ | 168,980 KB |
実行使用メモリ | 14,956 KB |
最終ジャッジ日時 | 2024-10-14 04:59:48 |
合計ジャッジ時間 | 14,432 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 TLE * 2 -- * 19 |
ソースコード
#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