結果

問題 No.2758 RDQ
ユーザー matcharate12matcharate12
提出日時 2023-02-04 14:20:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 169,972 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-09 19:49:29
合計ジャッジ時間 2,401 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++) //[0,n)
#define srep(i,a,b) for(int i = a; i < b; i++) //[a,b)
#define all(A) (A).begin(),(A).end()
#define rall(A) (A).rbegin(),(A).rend()
#define pmt(A) next_permutation(all(A))
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll,char>;
using pq = priority_queue<P,vector<P>,greater<P>>;
ll inf = 8e18;
int iinf = (int)1e9;
int mod9 = 998244353;
int mod1 = 1000000007;
struct Edge { int to; int cost; int from; };
bool compe(const Edge &e,const Edge &e2){ return e.cost < e2.cost; }
using Graph = vector<vector<ll>>;
using SGraph = vector<set<ll>>;
template <typename T>
int siz(T& a){return (int)a.size();}

int main(void){
	int n; cin >> n;
	ll k; cin >> k;
	vector<ll> B(n-1); rep(i,n-1) cin >> B[i];

	ll ok = 0,ng = (ll)1e18+1;
	bool judge = 0;
	while(abs(ok-ng) > 1){
		ll mid = (ok+ng) >> 1;

		vector<ll> A(n+1,0);
		A[0] = mid;
		ll sum = 0;
		rep(i,n) A[i+1] = B[i]+A[i];
		rep(i,n) sum += A[i];

		if(sum <= k){
			if(sum == k) judge = 1;
			ok = mid;
		}
		else ng = mid;
	}

	cout << (judge ? "Yes" : "No");
}
0