Submission #2366744
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; using p = pair<ll, ll>; int main(void) { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<ll> A(N); for (auto&& a : A) { cin >> a; } sort(A.begin(), A.end()); size_t survivor = N - 1; size_t least = 0; while (survivor != least) { auto ptr = lower_bound(A.begin(), A.end(), (A[survivor] + 1) / 2); least = survivor; survivor = ptr - A.begin(); } vector<ll> B = A; for (ll i = 1; i < N; i++) { B[i] += B[i - 1]; } least = 0; while (survivor != least) { auto ptr = lower_bound(B.begin(), B.end(), (A[survivor] + 1) / 2); least = survivor; survivor = ptr - B.begin(); } cout << N - survivor << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Creatures |
User | char_c3 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 924 Byte |
Status | AC |
Exec Time | 19 ms |
Memory | 1792 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | 19 ms | 1792 KB |
in3.txt | AC | 18 ms | 1792 KB |
in4.txt | AC | 18 ms | 1792 KB |
in5.txt | AC | 8 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 | 512 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |