結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
🍡yurahuna
|
| 提出日時 | 2016-02-26 15:04:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,248 bytes |
| コンパイル時間 | 767 ms |
| コンパイル使用メモリ | 74,672 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 11:17:05 |
| 合計ジャッジ時間 | 1,872 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#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();
}
🍡yurahuna