結果

問題 No.909 たぴの配置
ユーザー Jumbo_kprJumbo_kpr
提出日時 2019-10-18 21:37:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 3,000 ms
コード長 2,142 bytes
コンパイル時間 1,447 ms
コンパイル使用メモリ 109,452 KB
実行使用メモリ 9,284 KB
最終ジャッジ日時 2023-09-07 21:34:51
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,464 KB
testcase_01 AC 2 ms
7,472 KB
testcase_02 AC 2 ms
7,532 KB
testcase_03 AC 2 ms
7,456 KB
testcase_04 AC 2 ms
7,460 KB
testcase_05 AC 50 ms
9,024 KB
testcase_06 AC 51 ms
9,132 KB
testcase_07 AC 48 ms
8,904 KB
testcase_08 AC 53 ms
9,036 KB
testcase_09 AC 56 ms
9,284 KB
testcase_10 AC 50 ms
8,920 KB
testcase_11 AC 50 ms
9,172 KB
testcase_12 AC 49 ms
9,084 KB
testcase_13 AC 52 ms
9,144 KB
testcase_14 AC 50 ms
9,196 KB
testcase_15 AC 49 ms
8,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int MAX = 200060;
const double pi = acos(-1);
const ll INF = 1e18;


int X[300010], Y[300010];
ll ans[300010];

void solve() {
	int N; cin >> N;
	REP(i, N) {
		cin >> X[i];
	}
	REP(i, N)cin >> Y[i];
	int ok = 0, ng = 1e9;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		bool can = true;
		REP(i, N) {
			if (X[i] + Y[i] < mid) {
				can = false;
				break;
			}
		}
		if (can) {
			ok = mid;
		}
		else ng = mid;
	}
	print(ok);
	ans[0] = 0;
	ans[N + 1] = ok;
	REP(i, N) {
		if (Y[i] >= ok)ans[i+1] = 0;
		else if (X[i] >= ok)ans[i+1] = ok;
		else ans[i+1] = X[i];
	}
	REP(i, N + 2) {
		print(ans[i]);
	}
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();
}
0