結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-19 19:49:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 2,810 bytes |
| コンパイル時間 | 1,177 ms |
| コンパイル使用メモリ | 114,848 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-04 05:02:23 |
| 合計ジャッジ時間 | 2,220 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
//#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
vector<priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>> edge;
vector<bool> seen;
vll AN;
ll p = 1;
ll N;
void dfs(const Graph & G, int v) {
seen[v] = true; // v を訪問済にする
AN[v] = p;
// v から行ける各頂点 next_v について
while (!edge[v].empty()) {
ll next_v = edge[v].top().second;
edge[v].pop();
if (seen[next_v]) continue; // next_v が探索済だったらスルー
p++;
dfs(G, next_v); // 再帰的に探索
p++;
}
}
vll kB;
ll j = 0;
ll tt = 0;
void predfs(const Graph& G, int v) {
tt++;
seen[v] = true; // v を訪問済にする
AN[v] = p;
ll now = tt;
j++;
// v から行ける各頂点 next_v について
ll pe = 0;
for (auto next_v : G[v]) {
pe++;
if (seen[next_v]) continue; // next_v が探索済だったらスルー
/*if (pe == G[v].size()) {
edge[v].push(make_pair(N-now, next_v));
}*/
ll M = j;
predfs(G, next_v); // 再帰的に探索
edge[v].push(make_pair(j - M, next_v));
}
}
int main() {
ll NW, NB;
cin >> NW;
vll W(NW);
rep(i, NW)cin >> W[i];
cin >> NB;
vll B(NB);
rep(i, NB)cin >>B[i];
sort(all(W));
sort(all(B));
reverse(all(W));
reverse(all(B));
ll b = 0, w = 0;
ll anb = 0;
ll P = 1e18;
while (b < NB && w < NW) {
if (anb % 2 == 0) {
while (b<NB && B[b]>=P) {
b++;
}
if (b < NB) {
P = B[b];
anb++;
}
}
else {
while (w<NW && W[w]>=P) {
w++;
}
if (w < NW) {
anb++;
P = W[w];
}
}
}
ll anc = 0;
b = 0, w = 0;
P = 1e18;
while (b < NB && w < NW) {
if (anc % 2 != 0) {
while (b<NB && B[b]>=P) {
b++;
}
if (b < NB) {
P = B[b];
anc++;
}
}
else {
while (w<NW && W[w]>=P) {
w++;
}
if (w < NW) {
P = W[w];
anc++;
}
}
}
cout << max(anb, anc) << endl;
}