結果

問題 No.110 しましまピラミッド
ユーザー sggkshiosggkshio
提出日時 2017-04-11 02:14:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,267 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:58:58
合計ジャッジ時間 1,931 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int a, b;
	vector<int>A, B;
	cin >> a;
	for (int i = 0; i < a; i++) {
		int x;
		cin >> x;
		A.push_back(x);
	}
	cin >> b;
	for (int i = 0; i < b; i++) {
		int x;
		cin >> x;
		B.push_back(x);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	int t = 0, m = 0;
	int a1 = 0, a2 = 0;
	int r = 0;
	while (1) {
		if (r >= A[a - 1])break;
		for (; t < a; t++) {
			if (A[t] > r) {
				r = A[t];
				a1++;
				break;
			}
		}
		if (r >= B[b - 1])break;
		for (; m < b; m++) {
			if (B[m] > r) {
				r = B[m];
				a1++;
				break;
			}
		}
		if (t == a || m == b)break;
	}
	r = 0;
	t = 0, m = 0;
	while (1) {
		if (r >= B[b - 1])break;
		for (; m < b; m++) {
			if (B[m] > r) {
				r = B[m];
				a2++;
				break;
			}
			
		}
		if (r >= A[a - 1])break;
		for (; t < a; t++) {
			if (A[t] > r) {
				r = A[t];
				a2++;
				break;
			}
		}

		if (t == a || m == b)break;
	}
	cout << max(a1, a2) << endl;

	return 0;

}
0