반응형
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
int n;
int arr[101],p[101];
int sum = 0;
int ans = 0;
int count = 0 ;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
sum += arr[i];
}
sum = sum / 2;
sort(arr, arr + n, greater<>());
for (int i = 0; i < n; i++)
{
ans += arr[i];
if (ans > sum)
{
count = i+1;
break;
}
}
printf("%d", count);
}
https://codeforces.com/contest/160/problem/A
반응형
'🧩PS > 🥈Nomal' 카테고리의 다른 글
[C/C++] 백준 15969번 행복 (0) | 2020.04.08 |
---|---|
[C/C++] Codeforce 158B - Taxi (0) | 2020.04.04 |
[C/C++] Codeforce 1003C - Intense Heat (0) | 2020.04.04 |
[C/C++] Codeforce 466C - Number of Ways (0) | 2020.04.04 |
[C/C++] Codeforce 734B - Anton and Digits (0) | 2020.04.04 |