結果
| 問題 | No.1211 円環はお断り | 
| コンテスト | |
| ユーザー |  milanis48663220 | 
| 提出日時 | 2020-08-31 01:16:05 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,650 bytes | 
| コンパイル時間 | 1,144 ms | 
| コンパイル使用メモリ | 85,968 KB | 
| 実行使用メモリ | 19,944 KB | 
| 最終ジャッジ日時 | 2024-11-15 16:11:22 | 
| 合計ジャッジ時間 | 22,615 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 33 RE * 7 TLE * 1 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int N, K;
ll A[100005];
ll next_offset[100005][20];
// bool used[100005];
// void clear_used(){
//     for(int i = 0; i < N; i++) used[i] = false;
// }
void build(ll m){
    ll sum_sect = 0;
    int r = -1;
    for(int i = 0; i < N; i++){
        while(sum_sect < m){
            r++;
            if(r >= 2*N) sum_sect = INF;
            sum_sect += A[r%N];
        }
        next_offset[i][0] = r-i+1;
        sum_sect -= A[i];
    }
    for(int j = 1; j < 17; j++){
        for(int i = 0; i < N; i++){
            next_offset[i][j] = next_offset[i][j-1]+next_offset[(i+next_offset[i][j-1])%N][j-1];
        }
    }
}
vector<int> bt;
ll cnt(int s){
    ll ans = 0;
    for(int i : bt){
        // used[s] = true;
        ans += next_offset[s][i];
        s += next_offset[s][i];
        s %= N;
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < 17; i++){
        if(K&(1<<i)) bt.push_back(i);
    }
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll l = 1, r = INF;
    
    while(r-l > 1){
        ll c = (l+r)/2;
        // clear_used();
        build(c);
        bool ok = false;
        for(int i = 0; i < N; i++){
            // if(!used[i]){
                ll tmp = cnt(i);
                if(tmp <= N) ok = true;
            // }
        }
        if(ok) l = c;
        else r = c;
    }
    cout << l << endl;
}
            
            
            
        