結果

問題 No.110 しましまピラミッド
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-02-26 15:04:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,248 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 73,376 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:52:32
合計ジャッジ時間 1,784 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 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 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

#define PI 3.1415926535

typedef long long ll;
typedef pair<int, int> P;
//typedef complex<double> C;

const int MAX_L = 20;

int nw, nb;
int w[MAX_L + 1], b[MAX_L + 1];

void input() {
	cin >> nw;
	REP(i, nw) {
		int j;
		cin >> j;
		w[j] = 1;
	}
	cin >> nb;
	REP(i, nb) {
		int j;
		cin >> j;
		b[j] = 1;
	}
}

void solve() {
	int mx = -1;

	//白が頂点
	int cnt = 0;
	int pre = 1;	//w:0, b:1
	REP(i, MAX_L + 1) {
		if (w[i] == 1 && pre != 0) {
			cnt++;
			pre = 0;
		} else if (b[i] == 1 && pre != 1) {
			cnt++;
			pre = 1;
		}
	}
	mx = cnt;

	//黒が頂点
	cnt = 0;
	pre = 0;	//w:0, b:1
	REP(i, MAX_L + 1) {
		if (w[i] == 1 && pre != 0) {
			cnt++;
			pre = 0;
		} else if (b[i] == 1 && pre != 1) {
			cnt++;
			pre = 1;
		}
	}
	mx = max(mx, cnt);

	cout << mx << endl;
}

int main() {
	input();
	solve();
}
0