結果

問題 No.1139 Slime Race
ユーザー forest3forest3
提出日時 2020-08-01 16:16:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 652 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 166,428 KB
実行使用メモリ 4,732 KB
最終ジャッジ日時 2023-09-15 03:02:30
合計ジャッジ時間 3,348 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 57 ms
4,732 KB
testcase_11 AC 50 ms
4,680 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 57 ms
4,672 KB
testcase_15 WA -
testcase_16 AC 69 ms
4,676 KB
testcase_17 AC 58 ms
4,584 KB
testcase_18 AC 48 ms
4,376 KB
testcase_19 AC 33 ms
4,380 KB
testcase_20 AC 31 ms
4,376 KB
testcase_21 AC 45 ms
4,416 KB
testcase_22 AC 57 ms
4,564 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N;
	long long D;
	cin >> N >> D;
	vector<long long> x( N );
	for( int i = 0; i < N; i++ ) {
		cin >> x[i];
	}
	vector<long long> v( N );
	for( int i = 0; i < N; i++ ) {
		cin >> v[i];
	}

	const long long INF = INT32_MAX;
	auto f = [&]( long long t ) -> long long
	{
		long long res = 0;
		for( int i = 0; i < N; i++ ) {
			res += v[i] * t;
			if( v[i] * t < 0 || res < 0 ) return INF;
		}
		return res;
	};

	long long l = 0;
	long long r = INF;
	while( r - l > 1 ) {
		long long m = (l + r) / 2;
		if( f( m ) >= D ) r = m;
		else l = m;
	}
	long long ans = r;

	cout << ans << endl;
}
0