QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188542#5481. Beast BulliesGamal74#WA 58ms7016kbC++201.5kb2023-09-25 22:53:252023-09-25 22:53:26

Judging History

你现在查看的是最新测评结果

  • [2023-09-25 22:53:26]
  • 评测
  • 测评结果:WA
  • 用时:58ms
  • 内存:7016kb
  • [2023-09-25 22:53:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define fi first
#define se second
#define pp push_back
#define all(x) (x).begin(), (x).end()
#define Ones(n) __builtin_popcount(n)
#define endl '\n'
#define mem(arrr, xx) memset(arrr,xx,sizeof arrr)
//#define int long long
#define debug(x) cout << (#x) << " = " << x << endl

void Gamal() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy[] = {-1, +1, +0, +0, +1, -1, +1, -1};

const double EPS = 1e-9;
const ll OO = 0X3F3F3F3F3F3F3F3F;
const int N = 2e5 + 5, INF = INT_MAX, MOD = 1e9 + 7, LOG = 20;


void solve() {
    int n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    sort(all(v), greater<>());
    sum -= v[0];
    if (v[0] > sum) {
        cout << 1 << endl;
        return;
    }
    ll pre = 0;
    for (int i = 1; i < n; ++i) {
        pre += v[i];
        if (pre >= v[0]) {
            cout << i + 1;
            return;
        }
    }
    assert(false);

}


signed main() {
    Gamal();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 58ms
memory: 7016kb

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'