QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#240015 | #5481. Beast Bullies | kareemsakkary# | WA | 58ms | 5216kb | C++14 | 1.5kb | 2023-11-05 07:27:31 | 2023-11-05 07:27:32 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define fr(n) for(ll i = 0 ; i < n ; i++)
#define frj(n) for(ll j = 0 ; j < n ; j++)
#define ll long long
#define files freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define Ksakkary ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
using namespace std;
ll gcd(ll a, ll b) {
if (b == 0) return a;
return gcd(b, a % b);
}
ll mult(ll a, ll b) {
return ((a % mod) * (b % mod)) % mod;
}
ll add(ll a, ll b) {
return ((a % mod) + (b % mod)) % mod;
}
ll subtract(ll a, ll b) {
return ((a % mod) - (b % mod) + (2 * mod)) % mod;
}
const unsigned ll N = 2e6 + 5;
int knightX[] = {-2, -2, 2, 2, 1, 1, -1, -1};
int knighty[] = {-1, 1, -1, 1, -2, 2, -2, 2};
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};
char di[] = {'D', 'L', 'U', 'R'};
void solve() {
int n ; cin >> n;
vector<int> arr(n);
fr(n){
cin >> arr[i];
}
sort(all(arr));
int mx = arr.back();
ll sum = 0;
for(int i = n-2 ; i>=0 ;i--){
sum += arr[i];
if(sum >= mx) {
cout << 1 + (n - 2 - i + 1);
return;
}
}
cout << 1 <<endl;
}
int main() {
Ksakkary
//#ifndef ONLINE_JUDGE
// files
//#endif
// sieve();
ll t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 58ms
memory: 5216kb
input:
500000 976631732 51389671 729809897 630844317 294721017 903231515 477913449 871071076 636104080 345822085 97441187 499323378 522845426 310022664 199310190 776622973 602672555 646874222 214723272 285341530 962727359 681361226 47426538 272153520 693133904 542337627 556307610 325596239 95738088 5495543...
output:
3
result:
wrong answer 1st lines differ - expected: '155101', found: '3'