結果
| 問題 |
No.2796 Small Matryoshka
|
| コンテスト | |
| ユーザー |
Moss_Local
|
| 提出日時 | 2024-06-28 21:33:46 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 758 bytes |
| コンパイル時間 | 2,093 ms |
| コンパイル使用メモリ | 107,992 KB |
| 実行使用メモリ | 13,764 KB |
| 最終ジャッジ日時 | 2024-06-28 21:33:54 |
| 合計ジャッジ時間 | 5,619 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 1 TLE * 1 -- * 15 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct Matryoshka {
int r, R;
};
bool compare(const Matryoshka &a, const Matryoshka &b) { return a.R < b.R; }
int main() {
int N;
cin >> N;
vector<Matryoshka> dolls(N);
for(int i = 0; i < N; ++i) {
cin >> dolls[i].r >> dolls[i].R;
}
sort(dolls.begin(), dolls.end(), compare);
vector<int> dp(N, 1);
for(int i = 1; i < N; ++i) {
for(int j = 0; j < i; ++j) {
if(dolls[j].R <= dolls[i].r) {
dp[i] = max(dp[i], dp[j] + 1);
}
}
}
int maxDolls = *max_element(dp.begin(), dp.end());
int operationsB = N - maxDolls;
cout << operationsB << endl;
return 0;
}
Moss_Local