結果
問題 | No.8009 異なる数字の最大の範囲(勉強会用) |
ユーザー | 田中二郎 |
提出日時 | 2024-04-27 09:27:23 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,538 bytes |
コンパイル時間 | 3,358 ms |
コンパイル使用メモリ | 252,216 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-15 10:21:43 |
合計ジャッジ時間 | 4,532 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 8 ms
5,248 KB |
testcase_16 | AC | 7 ms
5,248 KB |
testcase_17 | WA | - |
testcase_18 | AC | 11 ms
5,248 KB |
testcase_19 | AC | 8 ms
5,248 KB |
testcase_20 | AC | 5 ms
5,248 KB |
testcase_21 | AC | 4 ms
5,248 KB |
testcase_22 | AC | 6 ms
5,248 KB |
testcase_23 | AC | 4 ms
5,248 KB |
testcase_24 | AC | 10 ms
5,248 KB |
ソースコード
#if !__INCLUDE_LEVEL__ #include __FILE__ int main() { ll n; in(n); vl A(n); in(A); ll l, r; l = r = 0; ll ans = 1; vb used(*max_element(ALL(A)), false); used[A[l]] = true; while (l <= r && r < n - 1) { if (!used[A[r + 1]]) { ++r; used[A[r]] = true; } else { used[A[l]] = false; ++l; } ans = max(ans, r - l + 1); } print(ans); return 0; } #else #include <bits/stdc++.h> #include <ranges> using namespace std; // clang-format off #define REP(i, n) for(ll i = 0; i < ll(n); i++) // [0, n): 0, 1,... ,n-1 #define rep(i, l, r) for(ll i = l; i < ll(r); i++) // [l, r): l, l+1,... ,r-1 #define rrep(i, r, l) for(ll i = r; i >= ll(l); i--) // [l, r]: r, r-1,... ,l <!!閉区間!!> #define ALL(v) (v).begin(), (v).end() #define QQQLX_OVERLOAD(e1, e2, e3, NAME, ...) NAME #define QQQlx1(x, BODY) [&](const auto &x) { return BODY; } #define QQQlx2(x, y, BODY) [&](const auto &x, const auto &y) { return BODY; } #define lx(...) QQQLX_OVERLOAD(__VA_ARGS__, QQQlx2, QQQlx1)(__VA_ARGS__) using ll = long long;using pll = pair<ll, ll>;using vl = vector<ll>;using vvl = vector<vector<ll>>;using vb=vector<bool>; istream& operator>>(istream& is, vl& vec) {assert(vec.size()>0);for(auto& e: vec)is>>e; return (is);} constexpr ll INF = 1e18;constexpr int LIMIT=1e5+1; struct IOSetup {IOSetup() {cin.tie(nullptr);ios_base::sync_with_stdio(false);cout << fixed << setprecision(20);}} iosetup; bool inside(ll x, ll y, ll h, ll w) {return 0 <= x && x < h && 0 <= y && y < w;}; vector<pll> dr = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; #ifdef _DEBUG #include "debug3.cpp" template <class T> void show_arr2D(const vector<vector<T>> &arr){REP(i,arr.size()){REP(j,arr[i].size())if(arr[i][j]<100)printf("%2lld ",arr[i][j]);else{cout << "bg" << " ";}cout << endl;}} #else #define de(...) {} #endif struct Echo {} echo;struct join {join(string _s = "") : deli(_s) {}join(char _s) { deli = _s; }string deli;};void operator|(bool b, Echo e) { cout << (b ? "Yes" : "No") << endl; }template <class T> void operator|(T const &t, Echo e) { cout << t << endl; }template <class Iterable> string operator|(Iterable const &v, join j) {string res = "";if(!v.empty()) {res += to_string(v[0]);for(auto &&e : v | views::drop(1)) {res += j.deli;res += to_string(e);}}return res;} inline void in(void) { return; }template <typename First, typename... Rest>void in(First &first, Rest &...rest) {cin >> first;in(rest...);return;}void print() { cout << endl;}template <class T>void print(vector<T> &vec) { for (auto& a : vec) {cout << a;if (&a != &vec.back()) cout << " "; } cout << endl;}template <class T>void print(vector<vector<T>> &df) { for (auto& vec : df) {print(vec); }}template <class Head, class... Tail>void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);} template <typename T>concept LLtoLLFunc = requires(T func, ll arg) {{ func(arg) } -> std::same_as<ll>;};template <typename DomainType, LLtoLLFunc F>ll maximize(DomainType const &domain, F f) {ll res = -INF;for(auto &&x : domain) {res = max(res, f(x));}return res;}template <typename DomainType, LLtoLLFunc F>ll minimize(DomainType const &domain, F f) {ll res = INF;for(auto &&x : domain) {res = min(res, f(x));}return res;}template <LLtoLLFunc F> ll maximize(ll l, ll r, F f) {ll res = -INF;rep(i, l, r) { res = max(res, f(i)); }return res;}template <LLtoLLFunc F> ll minimize(ll l, ll r, F f) {ll res = INF;rep(i, l, r) { res = min(res, f(i)); }return res;} #endif