41862023-03-15 23:22:19tomi7Bejgli (80 pont)cpp11Wrong answer 8/808ms4992 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==n){
			cout<<vak<<'\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
base8/80
1Wrong answer0/03ms2644 KiB
2Wrong answer0/03ms2948 KiB
3Wrong answer0/43ms3256 KiB
4Accepted4/43ms3372 KiB
5Partially correct2/43ms3668 KiB
6Wrong answer0/43ms3536 KiB
7Wrong answer0/43ms3696 KiB
8Wrong answer0/43ms3764 KiB
9Wrong answer0/43ms3720 KiB
10Wrong answer0/43ms3724 KiB
11Wrong answer0/43ms3868 KiB
12Partially correct2/43ms4156 KiB
13Wrong answer0/43ms4004 KiB
14Wrong answer0/43ms4060 KiB
15Wrong answer0/43ms4008 KiB
16Wrong answer0/44ms4004 KiB
17Wrong answer0/44ms4004 KiB
18Wrong answer0/44ms4008 KiB
19Wrong answer0/46ms4260 KiB
20Wrong answer0/48ms4472 KiB
21Wrong answer0/46ms4780 KiB
22Wrong answer0/46ms4992 KiB