Task: | Youngling tournament |
Sender: | eXeP |
Submission time: | 2016-07-28 21:31:20 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.06 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.06 s | details |
#8 | ACCEPTED | 0.06 s | details |
#9 | ACCEPTED | 0.06 s | details |
#10 | ACCEPTED | 0.06 s | details |
#11 | ACCEPTED | 0.05 s | details |
#12 | ACCEPTED | 0.07 s | details |
#13 | ACCEPTED | 0.06 s | details |
#14 | ACCEPTED | 0.05 s | details |
#15 | ACCEPTED | 0.05 s | details |
#16 | ACCEPTED | 0.06 s | details |
#17 | ACCEPTED | 0.06 s | details |
#18 | ACCEPTED | 0.06 s | details |
#19 | ACCEPTED | 0.05 s | details |
#20 | ACCEPTED | 0.05 s | details |
#21 | ACCEPTED | 0.06 s | details |
#22 | ACCEPTED | 0.06 s | details |
#23 | ACCEPTED | 0.06 s | details |
#24 | ACCEPTED | 0.06 s | details |
#25 | ACCEPTED | 0.06 s | details |
#26 | ACCEPTED | 0.05 s | details |
#27 | ACCEPTED | 0.12 s | details |
#28 | ACCEPTED | 0.14 s | details |
#29 | ACCEPTED | 0.14 s | details |
#30 | ACCEPTED | 0.14 s | details |
#31 | ACCEPTED | 0.15 s | details |
#32 | ACCEPTED | 0.14 s | details |
#33 | ACCEPTED | 0.14 s | details |
#34 | ACCEPTED | 0.12 s | details |
#35 | ACCEPTED | 0.12 s | details |
#36 | ACCEPTED | 0.13 s | details |
#37 | ACCEPTED | 0.14 s | details |
#38 | ACCEPTED | 0.14 s | details |
#39 | ACCEPTED | 0.12 s | details |
#40 | ACCEPTED | 0.13 s | details |
#41 | ACCEPTED | 0.13 s | details |
#42 | ACCEPTED | 0.14 s | details |
#43 | ACCEPTED | 0.12 s | details |
#44 | ACCEPTED | 0.12 s | details |
#45 | ACCEPTED | 0.11 s | details |
#46 | ACCEPTED | 0.12 s | details |
#47 | ACCEPTED | 0.11 s | details |
#48 | ACCEPTED | 0.14 s | details |
#49 | ACCEPTED | 0.14 s | details |
#50 | ACCEPTED | 0.14 s | details |
#51 | ACCEPTED | 0.14 s | details |
#52 | ACCEPTED | 0.12 s | details |
#53 | ACCEPTED | 0.15 s | details |
#54 | ACCEPTED | 0.17 s | details |
#55 | ACCEPTED | 0.17 s | details |
#56 | ACCEPTED | 0.16 s | details |
#57 | ACCEPTED | 0.14 s | details |
#58 | ACCEPTED | 0.15 s | details |
#59 | ACCEPTED | 0.17 s | details |
#60 | ACCEPTED | 0.17 s | details |
#61 | ACCEPTED | 0.18 s | details |
#62 | ACCEPTED | 0.18 s | details |
#63 | ACCEPTED | 0.15 s | details |
#64 | ACCEPTED | 0.15 s | details |
#65 | ACCEPTED | 0.14 s | details |
#66 | ACCEPTED | 0.13 s | details |
#67 | ACCEPTED | 0.14 s | details |
#68 | ACCEPTED | 0.15 s | details |
#69 | ACCEPTED | 0.14 s | details |
#70 | ACCEPTED | 0.13 s | details |
#71 | ACCEPTED | 0.13 s | details |
#72 | ACCEPTED | 0.14 s | details |
#73 | ACCEPTED | 0.17 s | details |
#74 | ACCEPTED | 0.16 s | details |
Code
#include <bits/stdc++.h> #define i64 long long #define u64 unsigned long long #define i32 int #define u32 unsigned int #define pii pair<int, int> #define pll pair<long long, long long> #define ld long double #define defmod 1000000007 #define mati64(a,b) vector<vector<i64>>(a, vector<i64>(b, 0)); using namespace std; int n; vector<i64> f; multiset<i64> pir[60]; i64 k[101010], cf[101010]; i64 hb(i64 b){ for(int i = 61; i >= 0; i--){ if((b&1LL<<i)) return i; } return 0; } i64 su[60]; i64 rip(){ i64 re = 0, s = 0; for(int i = 0; i < 60; ++i){ if(pir[i].size() > 0){ if(*pir[i].begin() >= s) re++; if(pir[i].size() > 1){ //cout << *(pir[i].begin()++) << " vs " << s+*pir[i].begin() << endl; if(*(++pir[i].begin()) >= s+*pir[i].begin()) re++; } //cout << "re " << re << endl; } s+=su[i]; } return re; } int main(){ cin.sync_with_stdio(0); cin.tie(0); cin >> n; f = vector<i64>(n); for(int i = 0; i < n; ++i){ cin >> f[i]; i64 hb1 = hb(f[i]); su[hb1]+=f[i]; pir[hb1].insert(f[i]); //cout << f[i] << " " << hb1 << endl; } cout << rip() << endl; int m; cin >> m; for(int i = 0; i < m; ++i){ cin >> k[i] >> cf[i]; k[i]--; i64 hb1 = hb(f[k[i]]); pir[hb1].erase(pir[hb1].find(f[k[i]])); su[hb1]-=f[k[i]]; f[k[i]] = cf[i]; hb1 = hb(cf[i]); pir[hb1].insert(cf[i]); su[hb1]+=cf[i]; //cout <<" hb" << cf[i] << " " << hb1 << endl; cout << rip() << endl; } return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3 2 1 3 3 1 3 2 7 ... |
correct output |
---|
3 2 3 2 |
user output |
---|
3 2 3 2 |
Test 2
Verdict: ACCEPTED
input |
---|
7 2 14 14 15 5 2 5 5 5 2 4 12 ... |
correct output |
---|
4 3 3 3 3 ... |
user output |
---|
4 3 3 3 3 ... |
Test 3
Verdict: ACCEPTED
input |
---|
10 1 3 40 6 2 20 7 79 80 100 10 9 58 10 40 ... |
correct output |
---|
7 6 6 6 5 ... |
user output |
---|
7 6 6 6 5 ... |
Test 4
Verdict: ACCEPTED
input |
---|
10 1 3 40 6 2 20 7 79 80 100 10 9 8 10 10 ... |
correct output |
---|
7 4 4 3 2 ... |
user output |
---|
7 4 4 3 2 ... |
Test 5
Verdict: ACCEPTED
input |
---|
10 1 3 40 6 2 20 7 79 80 100 10 9 80 10 4 ... |
correct output |
---|
7 7 3 2 4 ... |
user output |
---|
7 7 3 2 4 ... |
Test 6
Verdict: ACCEPTED
input |
---|
10 1 3 100 47 95 3 2 2 24 12 10 10 56 1 52 ... |
correct output |
---|
6 4 4 4 3 ... |
user output |
---|
6 4 4 4 3 ... |
Test 7
Verdict: ACCEPTED
input |
---|
10 1 3 100 47 95 3 2 2 24 12 10 10 6 1 2 ... |
correct output |
---|
6 5 5 5 4 ... |
user output |
---|
6 5 5 5 4 ... |
Test 8
Verdict: ACCEPTED
input |
---|
10 1 3 100 47 95 3 2 2 24 12 10 10 91 2 2 ... |
correct output |
---|
6 5 5 5 4 ... |
user output |
---|
6 5 5 5 4 ... |
Test 9
Verdict: ACCEPTED
input |
---|
100 189 48 295 293 281 74 10000 10... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 10
Verdict: ACCEPTED
input |
---|
100 189 48 295 293 281 74 10000 10... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 11
Verdict: ACCEPTED
input |
---|
100 189 48 295 293 281 74 10000 10... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 12
Verdict: ACCEPTED
input |
---|
100 37 10000 10000 10000 137 58 10... |
correct output |
---|
5 4 4 4 3 ... |
user output |
---|
5 4 4 4 3 ... |
Test 13
Verdict: ACCEPTED
input |
---|
100 37 10000 10000 10000 137 58 10... |
correct output |
---|
5 2 2 2 2 ... |
user output |
---|
5 2 2 2 2 ... |
Test 14
Verdict: ACCEPTED
input |
---|
100 37 10000 10000 10000 137 58 10... |
correct output |
---|
5 2 2 2 2 ... |
user output |
---|
5 2 2 2 2 ... |
Test 15
Verdict: ACCEPTED
input |
---|
1000 117690 118480 116698 116498 73... |
correct output |
---|
3 3 3 3 3 ... |
user output |
---|
3 3 3 3 3 ... |
Test 16
Verdict: ACCEPTED
input |
---|
1000 117690 118480 116698 116498 73... |
correct output |
---|
3 2 2 2 2 ... |
user output |
---|
3 2 2 2 2 ... |
Test 17
Verdict: ACCEPTED
input |
---|
1000 117690 118480 116698 116498 73... |
correct output |
---|
3 2 2 2 2 ... |
user output |
---|
3 2 2 2 2 ... |
Test 18
Verdict: ACCEPTED
input |
---|
1000 1709 376 1086 1000000 3107 278... |
correct output |
---|
4 4 4 4 4 ... |
user output |
---|
4 4 4 4 4 ... |
Test 19
Verdict: ACCEPTED
input |
---|
1000 1000000 1000000 1000000 100000... |
correct output |
---|
3 2 2 3 3 ... |
user output |
---|
3 2 2 3 3 ... |
Test 20
Verdict: ACCEPTED
input |
---|
1000 2951 1970 2237 1000000 1057 25... |
correct output |
---|
3 3 3 3 3 ... |
user output |
---|
3 3 3 3 3 ... |
Test 21
Verdict: ACCEPTED
input |
---|
10000 1000000000 1000000000 5855 100... |
correct output |
---|
3 3 3 3 3 ... |
user output |
---|
3 3 3 3 3 ... |
Test 22
Verdict: ACCEPTED
input |
---|
10000 1000000000 1000000000 5855 100... |
correct output |
---|
3 2 2 2 2 ... |
user output |
---|
3 2 2 2 2 ... |
Test 23
Verdict: ACCEPTED
input |
---|
10000 1000000000 1000000000 5855 100... |
correct output |
---|
3 2 2 2 2 ... |
user output |
---|
3 2 2 2 2 ... |
Test 24
Verdict: ACCEPTED
input |
---|
10000 19032 1470 1806 23678 10000000... |
correct output |
---|
5 3 3 3 3 ... |
user output |
---|
5 3 3 3 3 ... |
Test 25
Verdict: ACCEPTED
input |
---|
10000 14039 13924 27761 8322 8912 68... |
correct output |
---|
6 6 6 6 6 ... |
user output |
---|
6 6 6 6 6 ... |
Test 26
Verdict: ACCEPTED
input |
---|
10000 14880 1000000000 1000000000 10... |
correct output |
---|
9 9 3 3 3 ... |
user output |
---|
9 9 3 3 3 ... |
Test 27
Verdict: ACCEPTED
input |
---|
50000 1000000000000 364674496414 128... |
correct output |
---|
4 4 4 4 4 ... |
user output |
---|
4 4 4 4 4 ... |
Test 28
Verdict: ACCEPTED
input |
---|
50000 1000000000000 364674496414 128... |
correct output |
---|
4 2 2 2 2 ... |
user output |
---|
4 2 2 2 2 ... |
Test 29
Verdict: ACCEPTED
input |
---|
50000 1000000000000 364674496414 128... |
correct output |
---|
4 2 3 3 2 ... |
user output |
---|
4 2 3 3 2 ... |
Test 30
Verdict: ACCEPTED
input |
---|
50000 1000000000000 60494 106399 100... |
correct output |
---|
12 11 10 10 10 ... |
user output |
---|
12 11 10 10 10 ... |
Test 31
Verdict: ACCEPTED
input |
---|
50000 137138 68579 80891 12876 12790... |
correct output |
---|
12 3 3 3 3 ... |
user output |
---|
12 3 3 3 3 ... |
Test 32
Verdict: ACCEPTED
input |
---|
50000 1000000000000 18780 1000000000... |
correct output |
---|
13 3 3 3 3 ... |
user output |
---|
13 3 3 3 3 ... |
Test 33
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
4 4 4 4 4 ... |
user output |
---|
4 4 4 4 4 ... |
Test 34
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
4 2 2 2 2 ... |
user output |
---|
4 2 2 2 2 ... |
Test 35
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
4 2 2 2 2 ... |
user output |
---|
4 2 2 2 2 ... |
Test 36
Verdict: ACCEPTED
input |
---|
50000 29257 1000000000000 11645 2409... |
correct output |
---|
14 14 14 12 12 ... |
user output |
---|
14 14 14 12 12 ... |
Test 37
Verdict: ACCEPTED
input |
---|
50000 14532 1000000000000 17273 2604... |
correct output |
---|
13 2 2 2 2 ... |
user output |
---|
13 2 2 2 2 ... |
Test 38
Verdict: ACCEPTED
input |
---|
50000 1000000000000 13888 1000000000... |
correct output |
---|
14 14 12 12 12 ... |
user output |
---|
14 14 12 12 12 ... |
Test 39
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
6 6 6 6 5 ... |
user output |
---|
6 6 6 6 5 ... |
Test 40
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
6 4 4 3 3 ... |
user output |
---|
6 4 4 3 3 ... |
Test 41
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
6 3 3 3 3 ... |
user output |
---|
6 3 3 3 3 ... |
Test 42
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
28 25 25 25 25 ... |
user output |
---|
28 25 25 25 25 ... |
Test 43
Verdict: ACCEPTED
input |
---|
50000 1 1 1 1 1 1 1 1000000000000 1 ... |
correct output |
---|
27 2 2 2 2 ... |
user output |
---|
27 2 2 2 2 ... |
Test 44
Verdict: ACCEPTED
input |
---|
50000 1000000000000 1000000000000 10... |
correct output |
---|
27 24 22 22 7 ... |
user output |
---|
27 24 22 22 7 ... |
Test 45
Verdict: ACCEPTED
input |
---|
50000 100000 100000 100000 100000 10... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 46
Verdict: ACCEPTED
input |
---|
50000 100000 100000 100000 100000 10... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 47
Verdict: ACCEPTED
input |
---|
50000 100000 100000 100000 100000 10... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 48
Verdict: ACCEPTED
input |
---|
50000 100000 100000 100000 100000 10... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 49
Verdict: ACCEPTED
input |
---|
50000 722 100000 100000 5989 100000 ... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 50
Verdict: ACCEPTED
input |
---|
50000 9132 100000 100000 100000 3077... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 51
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 5 5 5 5 ... |
user output |
---|
5 5 5 5 5 ... |
Test 52
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 2 2 2 2 ... |
user output |
---|
5 2 2 2 2 ... |
Test 53
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 2 2 2 2 ... |
user output |
---|
5 2 2 2 2 ... |
Test 54
Verdict: ACCEPTED
input |
---|
100000 12649 85081 263931 249102 9739... |
correct output |
---|
10 6 6 6 6 ... |
user output |
---|
10 6 6 6 6 ... |
Test 55
Verdict: ACCEPTED
input |
---|
100000 1000000000000 113645 43822 250... |
correct output |
---|
10 3 3 3 3 ... |
user output |
---|
10 3 3 3 3 ... |
Test 56
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
11 3 3 3 3 ... |
user output |
---|
11 3 3 3 3 ... |
Test 57
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 5 5 5 5 ... |
user output |
---|
5 5 5 5 5 ... |
Test 58
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 2 2 2 2 ... |
user output |
---|
5 2 2 2 2 ... |
Test 59
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 5 5 5 2 ... |
user output |
---|
5 5 5 5 2 ... |
Test 60
Verdict: ACCEPTED
input |
---|
100000 41613 13664 63607 100000000000... |
correct output |
---|
11 11 11 10 10 ... |
user output |
---|
11 11 11 10 10 ... |
Test 61
Verdict: ACCEPTED
input |
---|
100000 1000000000000 40692 1000000000... |
correct output |
---|
11 2 2 2 2 ... |
user output |
---|
11 2 2 2 2 ... |
Test 62
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
12 8 2 2 2 ... |
user output |
---|
12 8 2 2 2 ... |
Test 63
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 5 5 5 5 ... |
user output |
---|
5 5 5 5 5 ... |
Test 64
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 3 3 3 3 ... |
user output |
---|
5 3 3 3 3 ... |
Test 65
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 10... |
correct output |
---|
5 5 3 3 3 ... |
user output |
---|
5 5 3 3 3 ... |
Test 66
Verdict: ACCEPTED
input |
---|
100000 1 1 1 1 1 1 1 1000000000000 1 ... |
correct output |
---|
27 25 25 25 25 ... |
user output |
---|
27 25 25 25 25 ... |
Test 67
Verdict: ACCEPTED
input |
---|
100000 1 1 1000000000000 100000000000... |
correct output |
---|
26 6 6 5 3 ... |
user output |
---|
26 6 6 5 3 ... |
Test 68
Verdict: ACCEPTED
input |
---|
100000 1000000000000 1000000000000 1 ... |
correct output |
---|
26 5 5 5 5 ... |
user output |
---|
26 5 5 5 5 ... |
Test 69
Verdict: ACCEPTED
input |
---|
100000 279 1623 100000 100000 100000 ... |
correct output |
---|
3 3 3 3 3 ... |
user output |
---|
3 3 3 3 3 ... |
Test 70
Verdict: ACCEPTED
input |
---|
100000 279 1623 100000 100000 100000 ... |
correct output |
---|
3 3 3 3 3 ... |
user output |
---|
3 3 3 3 3 ... |
Test 71
Verdict: ACCEPTED
input |
---|
100000 279 1623 100000 100000 100000 ... |
correct output |
---|
3 3 3 3 3 ... |
user output |
---|
3 3 3 3 3 ... |
Test 72
Verdict: ACCEPTED
input |
---|
100000 8815 100000 100000 100000 1000... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 73
Verdict: ACCEPTED
input |
---|
100000 20748 100000 100000 20644 1000... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |
Test 74
Verdict: ACCEPTED
input |
---|
100000 21734 6649 26577 100000 8081 5... |
correct output |
---|
2 2 2 2 2 ... |
user output |
---|
2 2 2 2 2 ... |