提出 #73562184
ソースコード 拡げる
#include <bits/stdc++.h>
#include <cctype>
#include <queue>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); } }init;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define rep(i,l,r) for (ll i = (ll)l; i < (ll)r; i++)
int main(){
Init();
ll N;
cin >> N;
vector<ll> A(N);
vector<bool> searched(N, false);
rep(i, 0, N){
cin >> A[i];
}
vector<ll> ids(N);
iota(ids.begin(), ids.end(), N);
sort(ids.begin(), ids.end(), [&](int i, int j){return A[i] < A[j];});
rep(i, 0, N-1){
if(A[ids[i]] == A[ids[i+1]] and A[ids[i]]+1 == A[ids[i+1]]){
continue;
}
else{
searched[ids[i]];
}
}
ll max_length = 1;
rep(i, 0, N){
if(searched[i]){
continue;
}
ll length = 1;
ll id = i;
rep(j, id, N){
if (A[j] == A[id] + 1){
searched[j] = true;
id = j;
length++;
max_length = max(max_length, length);
}
}
}
cout << max_length << endl;
}
提出情報
提出日時
2026-02-23 18:23:03+0900
問題
D - Max Straight
ユーザ
MatsumotoT
言語
C++23 (GCC 15.2.0)
得点
0
コード長
1345 Byte
結果
TLE
実行時間
> 2000 ms
メモリ
7440 KiB
コンパイルエラー
./Main.cpp: In function 'int main()':
./Main.cpp:41:28: warning: ignoring return value of 'constexpr std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](size_type) [with _Alloc = std::allocator<bool>; reference = std::vector<bool>::reference; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
41 | searched[ids[i]];
| ^
In file included from /opt/atcoder/gcc/include/c++/15.2.0/vector:69,
from /opt/atcoder/gcc/include/c++/15.2.0/functional:66,
from /opt/atcoder/gcc/include/c++/15.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:55,
from ./Main.cpp:1:
/opt/atcoder/gcc/include/c++/15.2.0/bits/stl_bvector.h:1156:7: note: declared here
1156 | operator[](size_type __n)
| ^~~~~~~~
ジャッジ結果
セット名
Sample
All
得点 / 配点
0 / 0
0 / 400
結果
セット名
テストケース
Sample
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt
ケース名
結果
実行時間
メモリ
00_sample_00.txt
AC
1 ms
3644 KiB
00_sample_01.txt
AC
1 ms
3644 KiB
00_sample_02.txt
AC
1 ms
3664 KiB
01_random_00.txt
AC
1 ms
3556 KiB
01_random_01.txt
AC
1 ms
3512 KiB
01_random_02.txt
AC
1 ms
3592 KiB
01_random_03.txt
AC
26 ms
7380 KiB
01_random_04.txt
AC
24 ms
7220 KiB
01_random_05.txt
TLE
> 2000 ms
5768 KiB
01_random_06.txt
AC
914 ms
4500 KiB
01_random_07.txt
TLE
> 2000 ms
7220 KiB
01_random_08.txt
AC
921 ms
4924 KiB
01_random_09.txt
AC
1 ms
3464 KiB
01_random_10.txt
TLE
> 2000 ms
7244 KiB
01_random_11.txt
TLE
> 2000 ms
7240 KiB
01_random_12.txt
AC
61 ms
3844 KiB
01_random_13.txt
TLE
> 2000 ms
7100 KiB
01_random_14.txt
AC
6 ms
3816 KiB
01_random_15.txt
TLE
> 2000 ms
7244 KiB
01_random_16.txt
AC
1587 ms
5572 KiB
01_random_17.txt
AC
26 ms
7240 KiB
01_random_18.txt
AC
25 ms
7300 KiB
01_random_19.txt
AC
27 ms
7240 KiB
01_random_20.txt
AC
19 ms
6152 KiB
01_random_21.txt
AC
36 ms
7440 KiB
01_random_22.txt
AC
4 ms
3752 KiB