結果
| 問題 |
No.3269 Leq-K Partition
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2025-09-12 22:16:56 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 229 ms / 6,000 ms |
| コード長 | 1,465 bytes |
| コンパイル時間 | 3,678 ms |
| コンパイル使用メモリ | 306,016 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2025-09-12 23:41:34 |
| 合計ジャッジ時間 | 7,266 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
VI a(n);
rep(i, n) cin >> a[i], a[i]--;
VI last(n, -1);
VI nxt(n);
rrep(i, n) nxt[i] = exchange(last[a[i]], i);
segtree<int, [](int x, int y) { return x + y; }, []() { return 0; }> seg(n);
rep(i, n) if (last[i] != -1) seg.set(last[i], 1);
VI ans(n + 1, 1);
VVI ks(n);
rep(k, n + 1) if (k) ks[0].emplace_back(k);
rep(i, n) {
for (int k : ks[i]) {
int r = seg.max_right(0, [&](int x) { return x <= k; });
if (r < n) ans[k]++, ks[r].emplace_back(k);
}
ks[i].clear();
ks[i].shrink_to_fit();
seg.set(i, 0);
if (nxt[i] != -1) seg.set(nxt[i], 1);
}
rep(i, n + 1) if (i) cout << ans[i] << '\n';
}
Kude