結果
問題 | No.2735 Demarcation |
ユーザー | FplusFplusF |
提出日時 | 2024-04-18 18:38:42 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,911 bytes |
コンパイル時間 | 3,155 ms |
コンパイル使用メモリ | 280,048 KB |
実行使用メモリ | 31,792 KB |
最終ジャッジ日時 | 2024-04-19 19:42:29 |
合計ジャッジ時間 | 8,499 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
17,828 KB |
testcase_01 | AC | 4 ms
11,124 KB |
testcase_02 | AC | 4 ms
11,028 KB |
testcase_03 | AC | 4 ms
11,112 KB |
testcase_04 | AC | 62 ms
18,784 KB |
testcase_05 | AC | 21 ms
11,900 KB |
testcase_06 | AC | 86 ms
17,372 KB |
testcase_07 | AC | 129 ms
18,328 KB |
testcase_08 | AC | 114 ms
17,972 KB |
testcase_09 | AC | 53 ms
13,820 KB |
testcase_10 | AC | 69 ms
14,988 KB |
testcase_11 | AC | 25 ms
12,568 KB |
testcase_12 | AC | 20 ms
11,704 KB |
testcase_13 | AC | 36 ms
11,932 KB |
testcase_14 | AC | 102 ms
16,368 KB |
testcase_15 | AC | 35 ms
11,736 KB |
testcase_16 | AC | 89 ms
17,400 KB |
testcase_17 | AC | 77 ms
14,784 KB |
testcase_18 | AC | 35 ms
12,568 KB |
testcase_19 | AC | 114 ms
18,208 KB |
testcase_20 | AC | 118 ms
17,848 KB |
testcase_21 | AC | 64 ms
16,196 KB |
testcase_22 | AC | 93 ms
18,516 KB |
testcase_23 | TLE | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template<class T> inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template<class T> inline bool chmax(T &a,T b){ if(a<b){ a=b; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); vector<ll> cnt(1000001,0); ll n; cin >> n; vector<ll> x(n); rep(i,n) cin >> x[i]; ll q; cin >> q; while(q--){ ll l,r,s; cin >> l >> r >> s; l--; ll w=r-l,ok=0; if((1ll<<min(61ll,w-1))<=s){ cout << "-1\n"; continue; } for(ll k=1;k<=w;k++){ vector<ll> vr(w,0); ll nr=0,sz=0; rep(nl,w){ auto g=[&](ll idx){ ll p=0; if(cnt[x[l+idx]]==0) p=1; return (sz+p)<=k; }; while(nr<w&&g(nr)){ if(cnt[x[l+nr]]==0) sz++; cnt[x[l+nr]]++; nr++; } vr[nl]=nr; cnt[x[l+nl]]--; if(cnt[x[l+nl]]==0) sz--; } vector<__int128> dp(w+1,0),sum(w+2,0); dp[0]=1; rep(i,w+1){ dp[i]+=sum[i]; if(s<dp[i]){ dp[w]=s+1; break; } if(i==w) break; sum[i+1]+=dp[i]; sum[1+vr[i]]-=dp[i]; sum[i+1]+=sum[i]; } if(dp[w]<=s) chmax(ok,k); else break; } cout << ok << '\n'; } }