結果
問題 | No.1995 CHIKA Road |
ユーザー |
|
提出日時 | 2022-07-01 21:48:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 360 ms / 2,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 805 ms |
コンパイル使用メモリ | 78,496 KB |
実行使用メモリ | 23,168 KB |
最終ジャッジ日時 | 2024-11-26 04:41:49 |
合計ジャッジ時間 | 5,627 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#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;}