Contest Duration: ~ (local time) (300 minutes) Back to Home

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 2019-08-03 18:05:23+0900 E - Osmium_1008と課題 hamayanhamayan C++14 (GCC 5.4.1) 300 2132 Byte AC 59 ms 1664 KB

#### Test Cases

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