QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468915#5481. Beast BulliesEiad_Ahmed#AC ✓60ms11148kbC++203.9kb2024-07-09 03:11:162024-07-09 03:11:16

Judging History

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

  • [2024-07-09 03:11:16]
  • 评测
  • 测评结果:AC
  • 用时:60ms
  • 内存:11148kb
  • [2024-07-09 03:11:16]
  • 提交

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;

    }
    cout<<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: 57ms
memory: 10972kb

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: 3712kb

input:

4
3
4
8
9

output:

3

result:

ok single line: '3'

Test #3:

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

input:

8
20
1
2
13
9
5
8
61

output:

1

result:

ok single line: '1'

Test #4:

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

input:

1
10

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 55ms
memory: 11136kb

input:

500000
488349
25720
365654
316274
147722
452008
239786
436076
318835
173398
49102
250556
262275
155533
100095
388891
302219
324219
107768
143112
481547
341758
23696
136464
347550
272004
279048
163397
48247
275611
118344
461362
410109
2256
76615
358107
240210
265807
435838
408622
38878
336952
171230
...

output:

154891

result:

ok single line: '154891'

Test #6:

score: 0
Accepted
time: 57ms
memory: 11148kb

input:

500000
999511652
999974281
999634347
999683727
999852279
999547993
999760215
999563925
999681166
999826603
999950899
999749445
999737726
999844468
999899906
999611110
999697782
999675782
999892233
999856889
999518454
999658243
999976305
999863537
999652451
999727997
999720953
999836604
999951754
999...

output:

262172

result:

ok single line: '262172'

Test #7:

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

input:

30
16
268435456
2048
32768
16777216
65536
131072
536870912
67108864
512
8
4194304
524288
4
1
8388608
33554432
262144
8192
256
32
2097152
128
4096
16384
1048576
134217728
64
1024
2

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 60ms
memory: 10968kb

input:

500000
976652749
51071855
732379151
633144920
294813539
904339860
479425162
872870196
638243905
346103305
97915062
501226286
524611259
310395471
199822607
779333750
605147990
648957289
215290850
285495798
962916507
684091230
47001297
272454876
695820020
543917748
558282177
326357439
96212988
5512266...

output:

154742

result:

ok single line: '154742'

Test #9:

score: 0
Accepted
time: 55ms
memory: 10956kb

input:

500000
653912
25720
370223
316974
147722
503094
239791
469456
319623
173398
49102
250570
262309
155533
100095
398057
302581
325201
107768
143112
606296
343747
23696
136464
350034
272070
279150
163397
48247
275690
118344
527503
426964
2256
76615
361714
240215
265850
469055
424778
38878
338612
171230
...

output:

190555

result:

ok single line: '190555'

Test #10:

score: 0
Accepted
time: 55ms
memory: 11052kb

input:

500000
655230
25720
370212
316954
147722
502533
239789
469006
319615
173398
49102
250563
262302
155533
100095
398151
302574
325220
107768
143112
607471
343694
23696
136464
349971
272058
279140
163397
48247
275679
118344
526711
426747
2256
76615
361671
240213
265842
468553
424623
38878
338570
171230
...

output:

200853

result:

ok single line: '200853'

Test #11:

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

input:

43
8
832040
233
1597
121393
24157817
4181
39088169
317811
3524578
9227465
165580141
10946
3
1
433494437
196418
6765
5702887
267914296
13
28657
34
377
987
701408733
514229
21
144
2
2178309
102334155
610
63245986
5
2584
1346269
14930352
89
46368
55
75025
17711

output:

3

result:

ok single line: '3'

Test #12:

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

input:

31
12
202383360
1544
24705
12648960
49410
98820
404766720
50595840
386
6
3162240
395280
3
1
6324480
25297920
197640
6176
193
24
1581120
96
3088
12352
790560
101191680
48
772
2
809533440

output:

1

result:

ok single line: '1'

Test #13:

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

input:

30
15
268435455
2047
32767
16777215
65535
131071
536870911
67108863
511
7
4194303
524287
3
1
8388607
33554431
262143
8191
255
31
2097151
127
4095
16383
1048575
134217727
63
1023
2

output:

1

result:

ok single line: '1'

Test #14:

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

input:

31
9
134217729
1025
16385
8388609
32769
65537
268435457
33554433
257
5
2097153
262145
3
1
4194305
16777217
131073
4097
129
17
1048577
65
2049
8193
524289
67108865
33
513
2
536870913

output:

26

result:

ok single line: '26'

Test #15:

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

input:

31
12
199229440
1520
24320
12451840
48640
97280
398458880
49807360
380
6
3112960
389120
3
1
6225920
24903680
194560
6080
190
24
1556480
95
3040
12160
778240
99614720
48
760
2
796917759

output:

30

result:

ok single line: '30'