41872023-03-15 23:26:40tomi7Bejgli (80 pont)cpp11Wrong answer 16/806ms5076 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(10101);
	int valasz=0;
	int v=0;
	int vak=0;
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	for(int i=0;i<10101;i++){
		cin>>a[i];
		if(valasz+a[i]>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+a[i]<n){
			valasz+=a[i];
			vak++;
		}
		if(valasz+a[i]==n){
			cout<<vak+1<<'\n';
			break;
		}
	}
	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
base16/80
1Wrong answer0/03ms2644 KiB
2Wrong answer0/03ms2948 KiB
3Accepted4/43ms3160 KiB
4Partially correct2/43ms3372 KiB
5Partially correct2/43ms3584 KiB
6Partially correct2/43ms3792 KiB
7Accepted4/43ms3896 KiB
8Wrong answer0/43ms3948 KiB
9Wrong answer0/43ms4144 KiB
10Wrong answer0/43ms4028 KiB
11Wrong answer0/43ms4024 KiB
12Partially correct2/43ms3948 KiB
13Wrong answer0/43ms4204 KiB
14Wrong answer0/43ms4164 KiB
15Wrong answer0/43ms4468 KiB
16Wrong answer0/44ms4380 KiB
17Wrong answer0/44ms4680 KiB
18Wrong answer0/44ms4896 KiB
19Wrong answer0/44ms4948 KiB
20Wrong answer0/43ms5076 KiB
21Wrong answer0/46ms5036 KiB
22Wrong answer0/44ms4992 KiB