提出 #55967873
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
int main() {
int N,M;
cin >> N >> M;
vector<int> A(N);
vector<int> B(M);
for(int &a: A) cin >> a;
for(int &b: B) cin >> b;
while(1) {
if (A.empty() && B.empty()) break;
// A のほう
if ((!A.empty() && B.empty()) ||
(!A.empty() && !B.empty() && A.front() <= B.front()) ) {
cout << A.front() << endl;
A.erase(A.begin());
} else if ((A.empty() && !B.empty()) ||
(!A.empty() && !B.empty() && A.front() > B.front() )) {
cout << B.front() << endl;
B.erase(B.begin());
}
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - マージ (Merge) |
| ユーザ | strkgr |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 100 |
| コード長 | 690 Byte |
| 結果 | AC |
| 実行時間 | 2 ms |
| メモリ | 3564 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 100 / 100 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample-01.txt, sample-02.txt |
| All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, sample-01.txt, sample-02.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01-01.txt | AC | 2 ms | 3424 KiB |
| 01-02.txt | AC | 2 ms | 3472 KiB |
| 01-03.txt | AC | 2 ms | 3396 KiB |
| 01-04.txt | AC | 2 ms | 3464 KiB |
| 01-05.txt | AC | 1 ms | 3472 KiB |
| 01-06.txt | AC | 1 ms | 3508 KiB |
| 01-07.txt | AC | 2 ms | 3400 KiB |
| 01-08.txt | AC | 2 ms | 3464 KiB |
| 01-09.txt | AC | 2 ms | 3496 KiB |
| 01-10.txt | AC | 2 ms | 3428 KiB |
| sample-01.txt | AC | 1 ms | 3480 KiB |
| sample-02.txt | AC | 1 ms | 3564 KiB |