結果
| 問題 |
No.8009 異なる数字の最大の範囲(勉強会用)
|
| ユーザー |
ramia777
|
| 提出日時 | 2022-04-24 12:04:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,992 bytes |
| コンパイル時間 | 775 ms |
| コンパイル使用メモリ | 96,148 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-06-12 22:38:45 |
| 合計ジャッジ時間 | 1,855 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 1 |
ソースコード
//
// Yukicoder
// No.3009
//#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>//list
#include <set> //tree
#include <map> //連想配列
#include <unordered_set> //hash
#include <unordered_map> //hash
#include <algorithm>
#include <iomanip>
#include <string>
#include <stdlib.h>
using namespace std;
typedef unsigned long long ULL;
typedef signed long long SLL;
typedef unsigned int UINT;
#define START (0)
#define RIGHT (1)
#define UP (2)
#define LEFT (3)
#define DOWN (4)
#define DATA_MAX (1000000)
#define FMAX(a,b) ((a)>(b)?(a):(b))
#define FMIN(a,b) ((a)<(b)?(a):(b))
vector <vector <SLL>> memo2;//二次元可変配列
vector<SLL> memo1;
vector<SLL> c;
vector<SLL> v;
vector<SLL> dp;
SLL H ,A, B, T, F, N, M, Result;
UINT hashtable;
SLL hashTable[1000005];
int main(int argc, char *argv[])
{
SLL a[100005];
cin >> N;
v.resize(N + 1);
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
//cout << "-----" << endl;
SLL L, R, ans=0, max_ans = 0,max_ans2 = 0;
//Nが1以下のとき
if (N <= 1)
{
cout << N << endl;
return 0;
}
//Nが2以上のとき
const int search_complete = 1;
const int search_break = 0;
int flag;
SLL i;
L = 0;
R = L;
flag = search_complete;
do {
if (hashTable[a[R]] == 0)
{
//バケット配列にインデックスをいれる(インデックス0と何もないの0を区別するために1から始める)
hashTable[a[R]] = R+1;
if (max_ans < R - L + 1 )
max_ans = R - L + 1;
}
else
{
flag = search_break;
}
//cout << "L=" << L << ",R=" << R << ",ans=" << max_ans << endl;
if (flag == search_break)
{
ans = 0;
if(L < hashTable[a[R]])
L = hashTable[a[R]]; //予め+1しているのでそのまま入れる
hashTable[a[R]] = R+1;
flag = search_complete;
}
R++;
} while (R < N);
cout << max_ans << endl;
///////////////////
//cout << endl;
//getchar();
return 0; //end
}
ramia777