Submission #73485920


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<ll, ll>m;
ll arr[200001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    for(ll i = 1; i<=n; i++){
        ll a;
        cin >> a;
        arr[i] = a;
    }
    for(ll i = 1; i<=n; i++){
        ll t = arr[i];
        if(m.find(t) == m.end())m.insert({t, 1});
        if(m.find(t-1) == m.end())continue;
        m[t] = max(m[t], m[t-1] + 1);
        //cout << t << ' ' << m[t] << '\n';
    }
    ll ma = 0;
    for(auto a : m){
        //cout << a.first << a.second << '\n';
        ma = max(a.second, ma);
    }
    cout << ma;
    return 0;

}   

Submission Info

Submission Time
Task D - Max Straight
User tonystar0420
Language C++23 (GCC 15.2.0)
Score 400
Code Size 696 Byte
Status AC
Exec Time 143 ms
Memory 17724 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 26
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3544 KiB
00_sample_01.txt AC 1 ms 3448 KiB
00_sample_02.txt AC 1 ms 3572 KiB
01_random_00.txt AC 1 ms 3548 KiB
01_random_01.txt AC 1 ms 3456 KiB
01_random_02.txt AC 1 ms 3644 KiB
01_random_03.txt AC 142 ms 17624 KiB
01_random_04.txt AC 143 ms 17528 KiB
01_random_05.txt AC 58 ms 11888 KiB
01_random_06.txt AC 25 ms 7732 KiB
01_random_07.txt AC 109 ms 17652 KiB
01_random_08.txt AC 23 ms 4216 KiB
01_random_09.txt AC 1 ms 3672 KiB
01_random_10.txt AC 56 ms 5212 KiB
01_random_11.txt AC 53 ms 5212 KiB
01_random_12.txt AC 5 ms 3820 KiB
01_random_13.txt AC 60 ms 5268 KiB
01_random_14.txt AC 2 ms 3672 KiB
01_random_15.txt AC 70 ms 5556 KiB
01_random_16.txt AC 35 ms 4588 KiB
01_random_17.txt AC 66 ms 17536 KiB
01_random_18.txt AC 61 ms 17280 KiB
01_random_19.txt AC 73 ms 17644 KiB
01_random_20.txt AC 50 ms 13456 KiB
01_random_21.txt AC 114 ms 17724 KiB
01_random_22.txt AC 8 ms 4828 KiB