Submission #6663888


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, M, K, E, A[201010], B[201010];
//---------------------------------------------------------------------------------------------------
int get(int energy) {
	ll tot = E;
	rep(i, 0, energy) tot += B[i];

	int cnt = 0;
	rep(i, 0, N) {
		if (tot < A[i]) return cnt;
		cnt++;
		tot -= A[i];
	}
	return cnt;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> K >> E;
	rep(i, 0, N) cin >> A[i];
	sort(A, A + N);
	rep(i, 0, M) cin >> B[i];
	sort(B, B + M, greater<int>());

	int ans = get(K);
	if (ans < N) {
		cout << "No" << endl;
		cout << ans << endl;
		return;
	}

	int ng = 0, ok = K;
	while (ng + 1 != ok) {
		int md = (ng + ok) / 2;
		if (get(md) == N) ok = md;
		else ng = md;
	}
	cout << "Yes" << endl;
	cout << ok << endl;
}

Submission Info

Submission Time
Task E - Osmium_1008と課題
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 300
Code Size 2132 Byte
Status AC
Exec Time 59 ms
Memory 1664 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 47
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt, small_05.txt, small_06.txt, small_07.txt, small_08.txt, small_09.txt, small_10.txt, small_11.txt, small_12.txt, small_13.txt, small_14.txt, small_15.txt, small_16.txt, small_17.txt, small_18.txt, small_19.txt, small_20.txt, large_01.txt, large_02.txt, large_03.txt, large_04.txt, large_05.txt, large_06.txt, large_07.txt, large_08.txt, large_09.txt, large_10.txt, large_11.txt, large_12.txt, large_13.txt, large_14.txt, large_15.txt, large_16.txt, large_17.txt, large_18.txt, large_19.txt, large_20.txt, corner_01.txt, corner_02.txt, corner_03.txt
Case Name Status Exec Time Memory
corner_01.txt AC 1 ms 256 KB
corner_02.txt AC 1 ms 256 KB
corner_03.txt AC 1 ms 256 KB
large_01.txt AC 39 ms 1280 KB
large_02.txt AC 34 ms 1024 KB
large_03.txt AC 31 ms 1024 KB
large_04.txt AC 37 ms 1152 KB
large_05.txt AC 52 ms 1536 KB
large_06.txt AC 24 ms 896 KB
large_07.txt AC 33 ms 1024 KB
large_08.txt AC 17 ms 640 KB
large_09.txt AC 16 ms 640 KB
large_10.txt AC 38 ms 1152 KB
large_11.txt AC 30 ms 1024 KB
large_12.txt AC 17 ms 640 KB
large_13.txt AC 50 ms 1408 KB
large_14.txt AC 19 ms 768 KB
large_15.txt AC 33 ms 1024 KB
large_16.txt AC 37 ms 1152 KB
large_17.txt AC 59 ms 1664 KB
large_18.txt AC 19 ms 768 KB
large_19.txt AC 8 ms 384 KB
large_20.txt AC 32 ms 1024 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
small_01.txt AC 2 ms 256 KB
small_02.txt AC 1 ms 256 KB
small_03.txt AC 2 ms 256 KB
small_04.txt AC 1 ms 256 KB
small_05.txt AC 1 ms 256 KB
small_06.txt AC 1 ms 256 KB
small_07.txt AC 1 ms 256 KB
small_08.txt AC 1 ms 256 KB
small_09.txt AC 1 ms 256 KB
small_10.txt AC 2 ms 256 KB
small_11.txt AC 1 ms 256 KB
small_12.txt AC 1 ms 256 KB
small_13.txt AC 1 ms 256 KB
small_14.txt AC 1 ms 256 KB
small_15.txt AC 1 ms 256 KB
small_16.txt AC 2 ms 256 KB
small_17.txt AC 1 ms 256 KB
small_18.txt AC 1 ms 256 KB
small_19.txt AC 1 ms 256 KB
small_20.txt AC 1 ms 256 KB