Submission #1675901


Source Code Expand

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/11  Problem: N18_b  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;
LL ans = 0LL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cin >> N;
	VL a(N,0);
	FOR(i, 0, N)cin >> a[i];
	SORT(a);

	VL sum(N + 1,0);
	sum[0] = 0;
	FOR(i, 1, N+1) {
		sum[i] = sum[i - 1] + a[i-1];
	}
	ans = 1;
	int f = 1;

	FORR(i, N-2, -1) {
		if (a[i+1] <= 2 * sum[i+1 ]&&f)ans++;
		else f = 0;
	}
	cout << ans << "\n";

	return 0;
}

Submission Info

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

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 18 ms 1792 KB
in10.txt AC 7 ms 896 KB
in11.txt AC 17 ms 1792 KB
in12.txt AC 13 ms 1792 KB
in13.txt AC 13 ms 1792 KB
in2.txt AC 18 ms 1792 KB
in3.txt AC 18 ms 1792 KB
in4.txt AC 18 ms 1792 KB
in5.txt AC 7 ms 896 KB
in6.txt AC 15 ms 1792 KB
in7.txt AC 18 ms 1792 KB
in8.txt AC 15 ms 1792 KB
in9.txt AC 3 ms 452 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB