結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー 田中二郎田中二郎
提出日時 2024-04-27 09:31:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,417 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 174,076 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 09:31:05
合計ジャッジ時間 2,743 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 7 ms
6,944 KB
testcase_16 AC 6 ms
6,940 KB
testcase_17 WA -
testcase_18 AC 11 ms
6,944 KB
testcase_19 AC 8 ms
6,940 KB
testcase_20 AC 4 ms
6,940 KB
testcase_21 AC 3 ms
6,944 KB
testcase_22 AC 5 ms
6,944 KB
testcase_23 AC 4 ms
6,944 KB
testcase_24 AC 10 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 (r < n - 1) {
    de(l, r);
    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
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)...);}
#endif
0