Submission #1157274
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; int a[N]; int n; bool check(int id) { ll s = a[id]; for (int i=1; i<=n; ++i) if (i != id) { if (a[i] > s*2) return false; s += a[i]; } return true; } int main() { scanf("%d", &n); for (int i=1; i<=n; ++i) { scanf("%d", &a[i]); } sort(a+1, a+n+1); int low = 1, high = n, ans = 0; while (low < high) { int mid = low + high >> 1; if (check(mid)) { ans = mid; high = mid; } else low = mid + 1; } if (ans) ans = n - ans + 1; printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Creatures |
User | RunningTime |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 710 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:19:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:21:27: 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 | 17 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 | 1 ms | 256 KB |