Submission #44053773


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll MOD=998244353;
// head
const int N=2e5+5;
int a[N],b[N];
vector<int> V;
signed main() 
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	int n,m;cin>>n>>m;
	for(int i=0;i<n;i++) {cin>>a[i];V.pb(a[i]);}
	for(int j=0;j<m;j++) {cin>>b[j];V.pb(b[j]);}
	sort(all(V));
	sort(a,a+n);
	sort(b,b+m);
	int sum=0,now=0;
	int i=0,j=0;
	while(i!=n&&a[i]<=sum){
			i++;
		}
	while(j!=m&&b[j]<sum){
		j++;
	}
	if(i>=m-j+1){
		cout<<sum<<endl;
		return 0;
	}
	while(now<=n+m)
	{
		sum=V[now];
		while(i!=n&&a[i]<=sum){
			i++;
		}
		while(j!=m&&b[j]<sum){
			j++;
		}
		// int tmp;
		// if(j==m) tmp=0;
		// else tmp=m-j+1;
		if(i>=m-j){
			cout<<sum<<endl;
			return 0;
		}
		sum=V[now]+1;
		while(i!=n&&a[i]<=sum){
			i++;
		}
		while(j!=m&&b[j]<sum){
			//cout<<b[j]<<" "<<sum<<endl;
			j++;
		}
		//cout<<sum<<" "<<i<<" "<<j<<endl;
		// if(j==m) tmp=0;
		// else tmp=m-j+1;
		if(i>=m-j){
			cout<<sum<<endl;
			return 0;
		}
		now++;
	}
}

Submission Info

Submission Time
Task C - Invisible Hand
User gangbengr
Language C++ (GCC 9.2.1)
Score 300
Code Size 1302 Byte
Status AC
Exec Time 105 ms
Memory 9580 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 44
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt, random_40.txt, random_41.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 105 ms 9540 KiB
random_02.txt AC 97 ms 9336 KiB
random_03.txt AC 93 ms 9340 KiB
random_04.txt AC 81 ms 9440 KiB
random_05.txt AC 99 ms 9576 KiB
random_06.txt AC 70 ms 9380 KiB
random_07.txt AC 60 ms 6680 KiB
random_08.txt AC 80 ms 9376 KiB
random_09.txt AC 98 ms 9580 KiB
random_10.txt AC 89 ms 9344 KiB
random_11.txt AC 66 ms 7256 KiB
random_12.txt AC 86 ms 9376 KiB
random_13.txt AC 37 ms 6244 KiB
random_14.txt AC 17 ms 4680 KiB
random_15.txt AC 38 ms 6240 KiB
random_16.txt AC 56 ms 9376 KiB
random_17.txt AC 32 ms 4920 KiB
random_18.txt AC 47 ms 6800 KiB
random_19.txt AC 48 ms 6472 KiB
random_20.txt AC 51 ms 6700 KiB
random_21.txt AC 17 ms 4108 KiB
random_22.txt AC 32 ms 5184 KiB
random_23.txt AC 61 ms 9440 KiB
random_24.txt AC 46 ms 6444 KiB
random_25.txt AC 36 ms 9380 KiB
random_26.txt AC 14 ms 4616 KiB
random_27.txt AC 13 ms 4668 KiB
random_28.txt AC 45 ms 9336 KiB
random_29.txt AC 15 ms 4740 KiB
random_30.txt AC 12 ms 4140 KiB
random_31.txt AC 27 ms 6184 KiB
random_32.txt AC 41 ms 9376 KiB
random_33.txt AC 44 ms 9336 KiB
random_34.txt AC 2 ms 3496 KiB
random_35.txt AC 2 ms 3560 KiB
random_36.txt AC 2 ms 3548 KiB
random_37.txt AC 2 ms 3496 KiB
random_38.txt AC 2 ms 3540 KiB
random_39.txt AC 2 ms 3500 KiB
random_40.txt AC 2 ms 3496 KiB
random_41.txt AC 2 ms 3544 KiB
sample_01.txt AC 2 ms 3548 KiB
sample_02.txt AC 2 ms 3432 KiB
sample_03.txt AC 2 ms 3488 KiB