Submission #1870460
Source Code Expand
#include <bits/stdc++.h> #define rank tipa_rank #define pb push_back #define mp make_pair #define ll long long #define ull unsigned long long #define INF 1000000000 #define EPS 1e-6 #define EPS2 1e-8 using namespace std; const ll MOD = INF + 7; using namespace std; int ans; int n; int a[100000]; bool good(int x) { ll sz = 0; for(int i = 0; i <= x; i++) { sz += a[i]; } bool good = true; for(int i = x + 1; i < n; i++) { if(a[i] <= 2 * sz) { sz += a[i]; } else { good = false; break; } } return good; } int main() { scanf("%d" , &n); for(int i = 0; i < n; i++) scanf("%d" , &a[i]); sort(a , a + n); int l = 0 , r = n - 1; while(abs(r - l) > 1) { int m = (l + r) / 2; if(good(m)) { r = m; } else { l = m + 1; } } if(l > r) { swap(l , r); } if(good(l)) { cout << n - l; } else cout << n - r; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Creatures |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 867 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:40:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d" , &n); ^ ./Main.cpp:42:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d" , &a[i]); ^
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 | 20 ms | 640 KB |
in10.txt | AC | 8 ms | 384 KB |
in11.txt | AC | 19 ms | 640 KB |
in12.txt | AC | 15 ms | 640 KB |
in13.txt | AC | 15 ms | 640 KB |
in2.txt | AC | 20 ms | 640 KB |
in3.txt | AC | 20 ms | 640 KB |
in4.txt | AC | 20 ms | 640 KB |
in5.txt | AC | 8 ms | 384 KB |
in6.txt | AC | 17 ms | 640 KB |
in7.txt | AC | 19 ms | 640 KB |
in8.txt | AC | 16 ms | 640 KB |
in9.txt | AC | 3 ms | 256 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 2 ms | 256 KB |