結果

問題 No.1995 CHIKA Road
ユーザー みここみここ
提出日時 2022-07-01 21:48:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 370 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 77,956 KB
実行使用メモリ 22,844 KB
最終ジャッジ日時 2023-08-17 09:21:19
合計ジャッジ時間 7,152 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 14 ms
4,548 KB
testcase_07 AC 49 ms
7,120 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,504 KB
testcase_10 AC 57 ms
4,488 KB
testcase_11 AC 370 ms
22,844 KB
testcase_12 AC 181 ms
13,540 KB
testcase_13 AC 89 ms
9,836 KB
testcase_14 AC 99 ms
10,196 KB
testcase_15 AC 304 ms
20,512 KB
testcase_16 AC 22 ms
5,252 KB
testcase_17 AC 114 ms
10,736 KB
testcase_18 AC 209 ms
15,348 KB
testcase_19 AC 209 ms
15,416 KB
testcase_20 AC 102 ms
9,992 KB
testcase_21 AC 91 ms
9,444 KB
testcase_22 AC 195 ms
14,880 KB
testcase_23 AC 49 ms
7,136 KB
testcase_24 AC 168 ms
13,276 KB
testcase_25 AC 27 ms
5,452 KB
testcase_26 AC 60 ms
7,716 KB
testcase_27 AC 162 ms
13,004 KB
testcase_28 AC 93 ms
9,396 KB
testcase_29 AC 203 ms
15,044 KB
testcase_30 AC 25 ms
5,520 KB
testcase_31 AC 13 ms
4,504 KB
testcase_32 AC 34 ms
6,164 KB
testcase_33 AC 152 ms
12,912 KB
testcase_34 AC 14 ms
4,564 KB
testcase_35 AC 55 ms
7,468 KB
testcase_36 AC 63 ms
8,092 KB
testcase_37 AC 181 ms
14,148 KB
testcase_38 AC 126 ms
11,524 KB
testcase_39 AC 11 ms
4,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    int a[100005], b[100005];
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        if (!mp.count(a[i]))
        {
            mp[a[i]] = 0;
        }
        mp[b[i]] = max(mp[b[i]], a[i]);
    }
    map<int, int> dp;
    dp[0] = -1;
    int last = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        last = max(last, dp[itr->second] + 1);
        dp[itr->first] = last;
    }
    cout << n * 2 - 2 - last << endl;
}
0