提出 #73490141


ソースコード 拡げる

#include <algorithm>
#include <iostream>
#include <map>
//#include <numeric>
#include <queue>
//#include <ranges>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define pb push_back
#define fr first
#define sc second
#define sor(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int,int>;
//using pll = pair<ll,ll>;
//using pqdec = priority_queue<int,vector<int>,greater<int>>;
//using pqdecl = priority_queue<ll,vector<ll>,greater<ll>>;
template <typename T>
using graph = vector<vector<T>>;
const ll LLMAX = 9223372*1e10;
const int IMAX = 214*1e7;
/*--------考察--------------------
----------CODING----------------*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    map<int,int> dp;
    rep(i,n){
        int a = v[i];
        if(!dp.contains(a-1) && !dp.contains(a)){
            dp[a] = 1;
        }
        else if(dp.contains(a-1)){
            dp[a] = dp[a-1]+1;
        }
    }
    int ans = -1;
    for(auto[_,c]:dp){
        ans = max(ans,c);
    }
    cout << ans << endl;
}

提出情報

提出日時
問題 D - Max Straight
ユーザ scotch_at
言語 C++23 (GCC 15.2.0)
得点 400
コード長 1299 Byte
結果 AC
実行時間 112 ms
メモリ 13632 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 26
セット名 テストケース
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 3508 KiB
00_sample_01.txt AC 1 ms 3592 KiB
00_sample_02.txt AC 1 ms 3412 KiB
01_random_00.txt AC 1 ms 3472 KiB
01_random_01.txt AC 1 ms 3628 KiB
01_random_02.txt AC 1 ms 3556 KiB
01_random_03.txt AC 82 ms 13628 KiB
01_random_04.txt AC 83 ms 13508 KiB
01_random_05.txt AC 58 ms 9264 KiB
01_random_06.txt AC 26 ms 6476 KiB
01_random_07.txt AC 112 ms 13632 KiB
01_random_08.txt AC 19 ms 3716 KiB
01_random_09.txt AC 1 ms 3540 KiB
01_random_10.txt AC 46 ms 4164 KiB
01_random_11.txt AC 45 ms 4288 KiB
01_random_12.txt AC 5 ms 3604 KiB
01_random_13.txt AC 51 ms 4212 KiB
01_random_14.txt AC 2 ms 3648 KiB
01_random_15.txt AC 58 ms 4332 KiB
01_random_16.txt AC 30 ms 3976 KiB
01_random_17.txt AC 52 ms 13508 KiB
01_random_18.txt AC 51 ms 13320 KiB
01_random_19.txt AC 66 ms 13580 KiB
01_random_20.txt AC 42 ms 10504 KiB
01_random_21.txt AC 93 ms 13508 KiB
01_random_22.txt AC 7 ms 4308 KiB