Submission #1370319


Source Code Expand

/**
 	Template created by Danel Batyrbek
 	All rights are reserved 2017 (lol)
*/

#include <bits/stdc++.h>

#define speed_up ios_base :: sync_with_stdio(0);cin.tie(0)
#define fr first
#define sc second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define debug(x) cerr << x << '\n';
#define YES "YES"
#define NO "NO"
#define skip continue
#define left(x) x << 1
#define rght(x) x << 1 | 1
#define forn(x, y, z) for(int x = y; x <= z; ++ x)
#define for1(x, y, z) for(int x = y; x >= z; -- x)
#define fname ""
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef double ld;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int N3 = 1e3 + 10;
const int INF = 2e9 + 10;
const ll LINF = 2e18;

int n, ans;
ll p[N]; 
ll pr[N];

int main(){
#ifndef DEBUG
	if(fname != ""){
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	}
#endif	
	cin >> n;
	forn(i, 1, n){
		cin >> p[i];
	}
	sort(p + 1, p + n + 1);
	forn(i, 1, n){
		pr[i] = pr[i - 1] + p[i];
	}
	ans = n;
	for1(i, n, 2){
		if(p[i] > pr[i - 1] * 2){
			ans -= i - 1;
			break;
		}
	}
	cout << ans;
	return 0;
}

Submission Info

Submission Time
Task B - Colorful Creatures
User KtlTheBest
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1232 Byte
Status AC
Exec Time 47 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:33: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  freopen(fname".in", "r", stdin);
                                 ^
./Main.cpp:44:35: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  freopen(fname".out", "w", stdout);
                                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
in1.txt AC 47 ms 1792 KB
in10.txt AC 15 ms 896 KB
in11.txt AC 39 ms 1792 KB
in12.txt AC 45 ms 1792 KB
in13.txt AC 45 ms 1792 KB
in2.txt AC 47 ms 1792 KB
in3.txt AC 47 ms 1792 KB
in4.txt AC 47 ms 1792 KB
in5.txt AC 19 ms 896 KB
in6.txt AC 33 ms 1792 KB
in7.txt AC 47 ms 1792 KB
in8.txt AC 33 ms 1792 KB
in9.txt AC 7 ms 384 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB