提出 #73512354


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull=unsigned long long;
const int INF = 1e9;
const long long INFLL = (long long)1e18;
const double PI = acos(-1);
//cout << fixed << setprecision(15) << ans << '\n';

int main()
{
    int n;cin>>n;
    unordered_map<ll,int>dp;
    int ans=1;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        if(dp.count(a-1))
        {
            if(dp.count(a))dp[a]=max(dp[a],dp[a-1]+1);
            else dp[a]=dp[a-1]+1;
        }
        else dp[a]=1;

        ans=max(ans,dp[a]);
    }


    cout<< ans<<endl;
  return 0;
}

提出情報

提出日時
問題 D - Max Straight
ユーザ maou1
言語 C++23 (Clang 21.1.0)
得点 400
コード長 652 Byte
結果 AC
実行時間 109 ms
メモリ 14088 KiB

コンパイルエラー

./Main.cpp:6:11: warning: unused variable 'INF' [-Wunused-const-variable]
    6 | const int INF = 1e9;
      |           ^~~
./Main.cpp:7:17: warning: unused variable 'INFLL' [-Wunused-const-variable]
    7 | const long long INFLL = (long long)1e18;
      |                 ^~~~~
2 warnings generated.

ジャッジ結果

セット名 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 3 ms 3040 KiB
00_sample_01.txt AC 1 ms 3092 KiB
00_sample_02.txt AC 1 ms 2968 KiB
01_random_00.txt AC 1 ms 3012 KiB
01_random_01.txt AC 1 ms 3132 KiB
01_random_02.txt AC 1 ms 3056 KiB
01_random_03.txt AC 69 ms 14004 KiB
01_random_04.txt AC 87 ms 13984 KiB
01_random_05.txt AC 64 ms 10112 KiB
01_random_06.txt AC 30 ms 6552 KiB
01_random_07.txt AC 109 ms 14088 KiB
01_random_08.txt AC 30 ms 3140 KiB
01_random_09.txt AC 1 ms 3116 KiB
01_random_10.txt AC 75 ms 3072 KiB
01_random_11.txt AC 81 ms 3140 KiB
01_random_12.txt AC 9 ms 3036 KiB
01_random_13.txt AC 80 ms 3216 KiB
01_random_14.txt AC 3 ms 3008 KiB
01_random_15.txt AC 81 ms 3420 KiB
01_random_16.txt AC 42 ms 3388 KiB
01_random_17.txt AC 93 ms 14000 KiB
01_random_18.txt AC 88 ms 13828 KiB
01_random_19.txt AC 98 ms 14064 KiB
01_random_20.txt AC 67 ms 11068 KiB
01_random_21.txt AC 100 ms 13880 KiB
01_random_22.txt AC 9 ms 3968 KiB