結果
問題 | No.2735 Demarcation |
ユーザー | FplusFplusF |
提出日時 | 2024-04-18 18:46:55 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,161 bytes |
コンパイル時間 | 3,839 ms |
コンパイル使用メモリ | 278,832 KB |
実行使用メモリ | 63,348 KB |
最終ジャッジ日時 | 2024-04-19 19:42:42 |
合計ジャッジ時間 | 15,971 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
11,136 KB |
testcase_01 | AC | 4 ms
11,096 KB |
testcase_02 | AC | 5 ms
11,096 KB |
testcase_03 | AC | 4 ms
11,136 KB |
testcase_04 | AC | 63 ms
18,964 KB |
testcase_05 | AC | 22 ms
11,716 KB |
testcase_06 | AC | 86 ms
17,408 KB |
testcase_07 | AC | 129 ms
18,328 KB |
testcase_08 | AC | 111 ms
18,176 KB |
testcase_09 | AC | 55 ms
13,952 KB |
testcase_10 | AC | 70 ms
14,848 KB |
testcase_11 | AC | 26 ms
12,632 KB |
testcase_12 | AC | 22 ms
11,540 KB |
testcase_13 | AC | 39 ms
11,972 KB |
testcase_14 | AC | 106 ms
16,452 KB |
testcase_15 | AC | 36 ms
11,784 KB |
testcase_16 | AC | 92 ms
17,536 KB |
testcase_17 | AC | 75 ms
14,716 KB |
testcase_18 | AC | 34 ms
12,836 KB |
testcase_19 | AC | 115 ms
18,376 KB |
testcase_20 | AC | 118 ms
17,776 KB |
testcase_21 | AC | 62 ms
16,220 KB |
testcase_22 | AC | 91 ms
18,468 KB |
testcase_23 | AC | 1,403 ms
25,112 KB |
testcase_24 | AC | 1,409 ms
35,728 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 1,417 ms
55,700 KB |
testcase_29 | WA | - |
ソースコード
#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); auto start=chrono::system_clock::now(); 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; } auto now=chrono::system_clock::now(); int ms=chrono::duration_cast<chrono::milliseconds>(now-start).count(); if(1400<=ms){ 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'; } }