結果

問題 No.110 しましまピラミッド
ユーザー otsnskotsnsk
提出日時 2014-12-24 15:26:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,247 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 67,148 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:46:46
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Block {
    int w;
    enum Color {white, black} color;
    Block(int nw=0, Color c=white): w(nw), color(c) {}
    bool operator<(const Block &o) const {
        return w < o.w;
    }
};

vector<Block> block;
int prev[30], h[30];

int main() {
    int Nw, Nb, w, N;
    cin >> Nw;
    block.push_back(Block(0, Block::white));
    for (int i = 0; i < Nw; i++) {
        cin >> w;
        block.push_back(Block(w, Block::white));
    }
    cin >> Nb;
    block.push_back(Block(0, Block::black));
    for (int i = 0; i < Nb; i++) {
        cin >> w;
        block.push_back(Block(w, Block::black));
    }
    N = Nw + Nb;

    sort(block.begin(), block.end());

    h[0] = h[1] = 0;
    for (int i = 2; i <= N + 1; i++) {
        for (int j = i - 1; j >= 0; j--) {
            if (block[j].color == block[i].color) continue;
            if (block[j].w < block[i].w) {
                h[i] = h[j] + 1;
                break;
            }
        }
    }
    int ans = h[N + 1];
    for (int i = N; i > 2; i--) {
        if (block[N+1].color == block[i].color) continue;
        ans = max(ans, h[i]);
        break;
    }
    cout << ans << endl;

    return 0;
}
0