QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468913#5481. Beast BulliesEiad_Ahmed#WA 60ms11096kbC++203.9kb2024-07-09 03:09:432024-07-09 03:09:43

Judging History

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

  • [2024-07-09 03:09:43]
  • 评测
  • 测评结果:WA
  • 用时:60ms
  • 内存:11096kb
  • [2024-07-09 03:09:43]
  • 提交

answer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>


#define INF 0x3f3f3f3f3f3f3f3f

#define ones(x) __builtin_popcountll(x)
#define memss(a, b, sz) memset(arr,b,sz * sizeof (arr[0]))
#define ii pair<ll ,ll >
#define PI ::acos(-1)
#define Eiado ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
typedef long long ll;
typedef long double ld;
#define int  ll
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

using namespace std;
using namespace __gnu_pbds;
template<typename T>
using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<long long, long long> pll;
typedef pair<ll, ll> pii;

template<typename T = ll>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v) in >> x;
    return in;
}

template<typename T = ll>
ostream &operator<<(ostream &out, const vector<T> &v) {
    for (const T &x: v) out << x << ' ';
    return out;
}
/*
 *

 */
///const int N = 5e5 + 5, b = 1e9 + 9, b2 = 31, mod = 1e9 + 7;
const ll inf = 1e18;
const ll M = 998244353;
const ld pi = atan2(0, -1);
const ld eps = 1e-6;
const int mod = 1e9 + 7;
#define x first
#define y second

int add(int a, int b) {
    return (a + b + mod) % mod;
}


void solve() {
    double n;
    cin >> n;
    vector<int> v(n);
    cin >> v;
    sort(rall(v));
    vector<int>pre(n+1);
    for (int i = 1; i <n+1 ; ++i) {
        pre[i]=pre[i-1]+v[i-1];
    }
    int last=1;
    for (int i = 2; i < n+1; ++i) {
        int  x=pre[i-1]*2;
        if(lower_bound(all(pre),x)==pre.end())
        {
            cout<<last;
            return;
        }
        last=lower_bound(all(pre),x)-pre.begin();
        i=last;

    }

}


signed main() {
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
    Eiado
    // priority_queue<PII, vector<PII>, greater<PII> > pq;
    //pq.emplace(a,make_pair(b,c));
    /*
                 E E E E     0                      D
                 E                                  D
                 E E E E     I    A A A         D D D
                 E           I   A     A       D    D
                 E E E E     I    A A A A       D D D
                                         A

*/
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();


    }


}


/*
 * int pw[N], pw2[N], inv[N], inv2[N], pref[N], pref2[N], prf[N],
        prf2[N];

int add(int a, int b) {
    return (a + b) % mod;
}

int mul(int a, int b) {
    return 1ll * a * b % mod;
}

int fp(int b, int p) {
    if (p == 0) return 1;
    int ret = fp(b, p >> 1);
    ret = mul(ret, ret);
    if (p & 1) ret = mul(ret, b);
    return ret;
}

void pre() {
    pw[0] = pw2[0] = inv[0] = inv2[0] = 1;
    int mul_inv = fp(b, mod - 2), mul_inv2 = fp(b2, mod - 2);
    for (int i = 1; i < N; i++) {
        pw[i] = mul(pw[i - 1], b);
        pw2[i] = mul(pw2[i - 1], b2);
        inv[i] = mul(inv[i - 1], mul_inv);
        inv2[i] = mul(inv2[i - 1], mul_inv2);
    }
}

pair<int, int> get_hash(int l, int r) {
    int ret = pref[r];
    if (l) ret = (ret - pref[l - 1] + mod) % mod;
    ret = mul(ret, inv[l]);
    int ret2 = pref2[r];
    if (l) ret2 = (ret2 - pref2[l - 1] + mod) % mod;
    ret2 = mul(ret2, inv2[l]);
    return {ret, ret2};
}

pair<int, int> get_hash2(int l, int r) {
    int ret = prf[r];
    if (l) ret = (ret - prf[l - 1] + mod) % mod;
    ret = mul(ret, inv[l]);
    int ret2 = prf2[r];
    if (l) ret2 = (ret2 - prf2[l - 1] + mod) % mod;
    ret2 = mul(ret2, inv2[l]);
    return {ret, ret2};
}

*/

详细

Test #1:

score: 100
Accepted
time: 60ms
memory: 11096kb

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:

155101

result:

ok single line: '155101'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

4
3
4
8
9

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

8
20
1
2
13
9
5
8
61

output:

1

result:

ok single line: '1'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3828kb

input:

1
10

output:


result:

wrong answer 1st lines differ - expected: '1', found: ''