41802023-03-15 22:11:17tomi7Bejgli (80 pont)cpp11Wrong answer 10/8090ms5768 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

/*long long lko(int n, int m){
	if(n%m==0 || m%n==0){
		return min(n, m);
	}
	if(n>m){
		return lko(n%m, m);
	}else{
		return lko(m%n, n);
	}
}*/
unsigned long long ghj(int i, unsigned long long n){
	unsigned long long segit=n;
	for(int j=1;j<i;j++){
		segit*=n;
	}
	return n;
}

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int valasz=0;
	int v=0;
	int vak=0;
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	for(int i=0;i<n;i++){
		if(valasz>n){
			valasz-=a[v];
			v++;
			vak--;
			for(int j=v;j<i;j++){
				if(valasz>n){
					valasz-=a[v];
					v++;
					vak--;
				}
			}
			valasz+=a[i];
			vak++;
		}else if(valasz==n){
			cout<<vak<<'\n';
			break;
		}else{
			valasz+=a[i];
			vak++;
		}
	}
	vector<int> c(101101);
	int vvalasz=0;
	int segit=0;
	for(int i=v;i<v+vak;i++){
        c[a[i]]++;
		if(segit<c[a[i]]){
			segit=c[a[i]];
			vvalasz=a[i];
		}
	}
	cout<<vvalasz<<'\n';
}
SubtaskSumTestVerdictTimeMemory
base10/80
1Wrong answer0/03ms2516 KiB
2Wrong answer0/03ms2704 KiB
3Wrong answer0/43ms2920 KiB
4Wrong answer0/43ms3128 KiB
5Partially correct2/43ms3212 KiB
6Accepted4/43ms3212 KiB
7Wrong answer0/43ms3352 KiB
8Wrong answer0/43ms3560 KiB
9Wrong answer0/43ms3776 KiB
10Wrong answer0/43ms3860 KiB
11Wrong answer0/44ms4060 KiB
12Partially correct2/44ms4320 KiB
13Wrong answer0/44ms4276 KiB
14Wrong answer0/44ms4280 KiB
15Wrong answer0/46ms4528 KiB
16Wrong answer0/47ms4744 KiB
17Wrong answer0/414ms4828 KiB
18Partially correct2/421ms5348 KiB
19Wrong answer0/428ms5348 KiB
20Wrong answer0/430ms5472 KiB
21Wrong answer0/437ms5564 KiB
22Wrong answer0/490ms5768 KiB