結果
問題 | No.2930 Larger Mex |
ユーザー | 👑 AngrySadEight |
提出日時 | 2024-10-12 16:18:45 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 366 ms / 2,000 ms |
コード長 | 3,912 bytes |
コンパイル時間 | 5,337 ms |
コンパイル使用メモリ | 223,900 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-10-12 16:19:08 |
合計ジャッジ時間 | 21,238 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
7,936 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 6 ms
8,064 KB |
testcase_03 | AC | 8 ms
8,064 KB |
testcase_04 | AC | 7 ms
7,936 KB |
testcase_05 | AC | 8 ms
8,064 KB |
testcase_06 | AC | 7 ms
7,936 KB |
testcase_07 | AC | 8 ms
7,936 KB |
testcase_08 | AC | 270 ms
11,776 KB |
testcase_09 | AC | 260 ms
11,520 KB |
testcase_10 | AC | 307 ms
11,904 KB |
testcase_11 | AC | 232 ms
11,264 KB |
testcase_12 | AC | 312 ms
13,440 KB |
testcase_13 | AC | 293 ms
12,672 KB |
testcase_14 | AC | 339 ms
14,464 KB |
testcase_15 | AC | 260 ms
13,440 KB |
testcase_16 | AC | 260 ms
12,672 KB |
testcase_17 | AC | 298 ms
12,928 KB |
testcase_18 | AC | 265 ms
13,056 KB |
testcase_19 | AC | 315 ms
14,336 KB |
testcase_20 | AC | 321 ms
14,592 KB |
testcase_21 | AC | 306 ms
13,696 KB |
testcase_22 | AC | 341 ms
15,744 KB |
testcase_23 | AC | 274 ms
13,440 KB |
testcase_24 | AC | 281 ms
13,312 KB |
testcase_25 | AC | 346 ms
17,920 KB |
testcase_26 | AC | 262 ms
11,888 KB |
testcase_27 | AC | 229 ms
11,512 KB |
testcase_28 | AC | 250 ms
11,552 KB |
testcase_29 | AC | 245 ms
11,544 KB |
testcase_30 | AC | 256 ms
11,464 KB |
testcase_31 | AC | 214 ms
11,380 KB |
testcase_32 | AC | 267 ms
11,512 KB |
testcase_33 | AC | 277 ms
11,560 KB |
testcase_34 | AC | 332 ms
14,720 KB |
testcase_35 | AC | 194 ms
11,136 KB |
testcase_36 | AC | 297 ms
14,720 KB |
testcase_37 | AC | 294 ms
13,056 KB |
testcase_38 | AC | 319 ms
14,464 KB |
testcase_39 | AC | 293 ms
14,976 KB |
testcase_40 | AC | 293 ms
14,592 KB |
testcase_41 | AC | 263 ms
13,440 KB |
testcase_42 | AC | 274 ms
10,972 KB |
testcase_43 | AC | 254 ms
10,796 KB |
testcase_44 | AC | 256 ms
11,464 KB |
testcase_45 | AC | 278 ms
11,460 KB |
testcase_46 | AC | 292 ms
5,248 KB |
testcase_47 | AC | 282 ms
5,248 KB |
testcase_48 | AC | 200 ms
5,248 KB |
testcase_49 | AC | 300 ms
5,248 KB |
testcase_50 | AC | 282 ms
12,756 KB |
testcase_51 | AC | 327 ms
18,176 KB |
testcase_52 | AC | 366 ms
18,816 KB |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <atcoder/all> #include <bitset> #include <cassert> #include <cmath> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using namespace atcoder; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--) #define repk(i, k, n) for (int i = k; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define mod1 1000000007 #define mod2 998244353 #define mod3 100000007 #define vi vector<int> #define vs vector<string> #define vc vector<char> #define vl vector<ll> #define vb vector<bool> #define vvi vector<vector<int>> #define vvc vector<vector<char>> #define vvl vector<vector<ll>> #define vvb vector<vector<bool>> #define vvvi vector<vector<vector<int>>> #define vvvl vector<vector<vector<ll>>> #define pii pair<int, int> #define pil pair<int, ll> #define pli pair<ll, int> #define pll pair<ll, ll> #define vpii vector<pair<int, int>> #define vpll vector<pair<ll, ll>> #define vvpii vector<vector<pair<int, int>>> #define vvpll vector<vector<pair<ll, ll>>> using mint = modint998244353; template <typename T> void debug(T e) { cerr << e << endl; } template <typename T> void debug(vector<T> &v) { rep(i, v.size()) { cerr << v[i] << " "; } cerr << endl; } template <typename T> void debug(vector<vector<T>> &v) { rep(i, v.size()) { rep(j, v[i].size()) { cerr << v[i][j] << " "; } cerr << endl; } } template <typename T> void debug(vector<pair<T, T>> &v) { rep(i, v.size()) { cerr << v[i].first << " " << v[i].second << endl; } } template <typename T> void debug(set<T> &st) { for (auto itr = st.begin(); itr != st.end(); itr++) { cerr << *itr << " "; } cerr << endl; } template <typename T> void debug(multiset<T> &ms) { for (auto itr = ms.begin(); itr != ms.end(); itr++) { cerr << *itr << " "; } cerr << endl; } template <typename T> void debug(map<T, T> &mp) { for (auto itr = mp.begin(); itr != mp.end(); itr++) { cerr << itr->first << " " << itr->second << endl; } } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << H << " "; debug_out(T...); } int main() { ll N, M; cin >> N >> M; vector<ll> A(N); for (ll i = 0; i < N; i++) { cin >> A[i]; } if (M == 0) { for (ll i = 0; i < N; i++) { cout << N - i << endl; } return 0; } vector<vector<ll>> idx(200001, vector<ll>(0)); for (ll i = 0; i < N; i++) { idx[A[i]].push_back(i); } vector<ll> now_idx(M, 0); bool has_zero = false; for (ll i = 0; i < M; i++) { if (idx[i].size() == 0) { has_zero = true; } now_idx[i] = 0; } if (has_zero) { for (ll i = 0; i < N; i++) { cout << 0 << endl; } return 0; } vector<ll> ans(N + 1, 0); ll now_max_idx = 0; for (ll i = 0; i < M; i++) { now_max_idx = max(now_max_idx, idx[i][0]); } for (ll i = 0; i < N; i++) { // debug_out(i, now_max_idx); ans[now_max_idx - i]++; ans[N - i]--; if (A[i] < M) { now_idx[A[i]]++; if (idx[A[i]].size() == now_idx[A[i]]) { break; } now_max_idx = max(now_max_idx, idx[A[i]][now_idx[A[i]]]); } } for (ll i = 0; i < N; i++) { ans[i + 1] += ans[i]; } for (ll i = 0; i < N; i++) { cout << ans[i] << endl; } }