Submission #14767064


Source Code Expand

/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int N = 400000;
int a[N], b[N], psa[N], psb[N], it1 = 0, it2 = 0;

int32_t main(){
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < N; i++){
		a[i] = 10000000000000000ll;
		b[i] = 10000000000000000ll;
		psa[i] = 10000000000000000ll;
		psb[i] = 10000000000000000ll;
	}
	psa[0] = 0;
	psb[0] = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		psa[i + 1] = (i == 0 ? a[0] : psa[i] + a[i]);
	}
	for (int i = 0; i < m; i++){
		cin >> b[i];
		psb[i + 1] = (i == 0 ? b[0] : psb[i] + b[i]);
	}
	int ans = 0;
	for (int i = 0; i <= n; i++){
		if (k < psa[i])
			continue;
		int x = k - psa[i];
//		for (int i = 0; i <= m + 1; i++){
//			cout << psb[i] << ' ';
//		}
//		cout << endl;
		int y = upper_bound(psb, psb + N, x) - psb - 1;
//		cout << y << endl;
		ans = max(ans, y + i);
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task C - Tsundoku
User Dorost
Language C++ (GCC 9.2.1)
Score 300
Code Size 1053 Byte
Status AC
Exec Time 145 ms
Memory 16052 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample a01.txt, a02.txt, a03.txt
All a01.txt, a02.txt, a03.txt, b04.txt, b05.txt, b06.txt, b07.txt, b08.txt, b09.txt, b10.txt, b11.txt, b12.txt, b13.txt, b14.txt, b15.txt, b16.txt, b17.txt, b18.txt, b19.txt, b20.txt
Case Name Status Exec Time Memory
a01.txt AC 18 ms 15968 KiB
a02.txt AC 21 ms 16000 KiB
a03.txt AC 20 ms 16032 KiB
b04.txt AC 17 ms 15940 KiB
b05.txt AC 145 ms 16000 KiB
b06.txt AC 91 ms 15872 KiB
b07.txt AC 20 ms 16036 KiB
b08.txt AC 99 ms 16004 KiB
b09.txt AC 56 ms 15928 KiB
b10.txt AC 58 ms 16000 KiB
b11.txt AC 60 ms 16036 KiB
b12.txt AC 66 ms 15968 KiB
b13.txt AC 103 ms 15996 KiB
b14.txt AC 93 ms 15928 KiB
b15.txt AC 95 ms 16052 KiB
b16.txt AC 91 ms 16048 KiB
b17.txt AC 93 ms 15936 KiB
b18.txt AC 92 ms 15968 KiB
b19.txt AC 86 ms 15852 KiB
b20.txt AC 61 ms 15880 KiB