結果

問題 No.2890 Chiffon
ユーザー 4094706840947068
提出日時 2024-09-19 15:50:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 3,687 bytes
コンパイル時間 3,488 ms
コンパイル使用メモリ 193,724 KB
実行使用メモリ 13,048 KB
最終ジャッジ日時 2024-09-19 15:50:50
合計ジャッジ時間 7,918 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 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 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 169 ms
13,048 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 69 ms
7,260 KB
testcase_34 AC 68 ms
7,260 KB
testcase_35 AC 68 ms
7,256 KB
testcase_36 AC 70 ms
7,256 KB
testcase_37 AC 68 ms
7,260 KB
testcase_38 AC 68 ms
7,228 KB
testcase_39 AC 69 ms
7,260 KB
testcase_40 AC 68 ms
7,292 KB
testcase_41 AC 68 ms
7,240 KB
testcase_42 AC 70 ms
7,256 KB
testcase_43 AC 69 ms
7,260 KB
testcase_44 AC 68 ms
7,260 KB
testcase_45 AC 79 ms
7,260 KB
testcase_46 AC 68 ms
7,260 KB
testcase_47 AC 68 ms
7,384 KB
testcase_48 AC 70 ms
7,256 KB
testcase_49 AC 68 ms
7,264 KB
testcase_50 AC 68 ms
7,264 KB
testcase_51 AC 68 ms
7,392 KB
testcase_52 AC 67 ms
7,260 KB
testcase_53 AC 16 ms
5,376 KB
testcase_54 AC 45 ms
5,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<sstream>
#include<algorithm>
#include<deque>
#include<list>
#include<map>
#include<memory>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<string.h>
#include<string>
#include<math.h>
#include<float.h>
#include<stdio.h>
#include<vector>
#include<iomanip>
#include<bitset>
#include<random>
#include<complex>
#include <cassert>
#include <utility>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T &a, T b) { return ((a>b) ? (a = b, true) : (false));}
#define rep(i,s,n) for(long long i=s;i<(long long)(n);i++)
#define rrep(i,s,n) for(long long i=n-1;i>=s;i--)
const long long inf = 1LL<<60;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//pairのsecondでソートsort(p.begin(),p.end(),cmp)
#define cmp [](pair<ll,ll> a, pair<ll,ll> b){return a.second<b.second;}
//cmpArg := 偏角ソート, atan2l(y, x); atan2l(y, x) = [-pi, pi]
#define cmpArg [](const auto &p1, const auto &p2) { return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first); }
typedef pair<long long, long long> P;
typedef pair<ll, pair<ll,ll> > PP;
#define rll ll,vector<ll>,greater<ll>
#define rP P,vector<P>,greater<P>
const long double pi = 3.14159265358979;
typedef unsigned long long ull;
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vmint vector<mint>
#define vvmint vector<vector<mint>>
#define vvch vector<vector<char>>
#define vch vector<char>
#define vstring vector<string>
#define rPP PP,vector<PP>,greater<PP>
#define vP vector<P> 
#define vvP vector<vector<P>>
#define vPP vector<PP>
#define all(x) x.begin(), x.end()
//UNIQUE(x) xをソートして値の被りがないようにする
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
int pc(ll x) { return __builtin_popcount(x); } //ビット列にどれだけ1がたっているかを求める pop count
//逆順のlower_bound(単調減少関数で自分以下を二分探索)するときは`ll index = lower_bound(all(inv), -a[i], greater<ll>()) - inv.begin();`, 逆からみたlis的なやつが作れる
//オバフロしない計算はa > inf - b および a > inf / bでとってね
//半分全列挙は前の方を(siz+1)/2ででかくする
//using mint = atcoder::modint, main関数でmint::set_mod(M)とすると任意modのmintにできる
//mapでも auto it = mp.lower_bound(key)としてlower_boundが使用できる while(it != mp.end())でループすることもできる

using mint = modint;

int main()
{
    int n,k; cin >> n >> k;
    vector<int> a(k); rep(i,0,k) cin >> a[i];
    int width = 1e9, idx = -1;
    rep(i,0,k-1) if(chmin(width, a[i+1] - a[i])) idx = i;
    vector<int> na;
    rep(i,idx,idx+k) {
        if(a[idx] > a[i%k]) a[i%k] += 2*n;
        na.push_back(a[i%k]);
    }
    rep(i,0,k) na.push_back(na[i]+2*n);
    a = na;
    int left = 0, right = n;
    while(right - left > 1) {
        int mid = (right + left) / 2;
        int x = 2* mid;
        auto cut = [&](int cur, int idx) -> int {
            //a[idx] ~ a[idx+1]までの間をカットする
            int nxt = cur + x;
            nxt = max(nxt, a[idx]+1);
            if(nxt >= a[idx+1]) return 1e9;
            return nxt;
        };
        bool can = false;
        for(int start=a[0]+1;start<a[1];start+=2) {
            int pos = start;
            rep(_,0,k-1) {
                pos = cut(pos, _+1);
            }
            if(start + 2*n - pos >= x) can = true;
        }
        if(can) left = mid;
        else right = mid;
    }
    cout << left*2 << endl;
}
0