CSES - Siperia opettaa 2.0 - Results
Submission details
Task:Greedy Game
Sender:Hansuzu
Submission time:2016-07-28 14:51:24 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.06 sdetails
#7ACCEPTED0.06 sdetails
#8ACCEPTED0.06 sdetails
#9ACCEPTED0.06 sdetails
#10ACCEPTED0.04 sdetails
#11ACCEPTED0.06 sdetails
#12ACCEPTED0.06 sdetails
#13ACCEPTED0.07 sdetails
#14ACCEPTED0.10 sdetails
#15ACCEPTED0.12 sdetails
#16ACCEPTED0.10 sdetails
#17ACCEPTED0.10 sdetails
#18ACCEPTED0.10 sdetails
#19ACCEPTED0.19 sdetails
#20ACCEPTED0.18 sdetails
#21ACCEPTED0.19 sdetails
#22ACCEPTED0.20 sdetails
#23ACCEPTED0.19 sdetails
#24ACCEPTED0.12 sdetails
#25ACCEPTED0.18 sdetails
#26ACCEPTED0.14 sdetails
#27ACCEPTED0.18 sdetails
#28ACCEPTED0.14 sdetails
#29ACCEPTED0.14 sdetails
#30ACCEPTED0.13 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<qq.size(); ++i){
                           ^
input/code.cpp:33:7: warning: unused variable 'mn' [-Wunused-variable]
   int mn=0;
       ^

Code

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define MP make_pair
#define F first
#define S second
using namespace std;
int n;

int a[101010];
vector<pair<int, int> > qq;

set<int> ok;
set<int>::iterator it;

int main(){
  for (int i=0; i<101010/2; ++i) ok.insert(-i);
  cin >> n;
  for (int i=0; i<n; ++i)cin >> a[i];
  for (int i=0; i<n; ++i){
    int b;
    cin >> b;
    qq.push_back(MP(a[i], b));
  }sort(qq.begin(), qq.end());
  qq.pop_back();
  for (int i=0; i<qq.size(); ++i){
    qq[i].F=qq.size()-i-1;
    swap(qq[i].F, qq[i].S);
  }
  sort(qq.begin(), qq.end());
  long long ans=0;
  int mn=0;
//   for (int i=0; i<qq.size(); ++i)cout << "qq[" << i << "]: <" << qq[i].F << ", " << qq[i].S << ">\n";
  
  for (int i=qq.size()-1; i>=0; --i){
    int v=qq[i].F;
    int ci=qq[i].S;
    it=ok.lower_bound(-ci/2);
    if (it==ok.end()) continue;
    ok.erase(it);
    ans+=v;
  }
  cout << ans << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
5
1 2 3 4 5
2 3 4 5 6

correct output
8

user output
8

Test 2

Verdict: ACCEPTED

input
10
1 1 1 1 1 1 1 1 1 1
2 3 9 5 6 6 1 2 3 4

correct output
17

user output
17

Test 3

Verdict: ACCEPTED

input
15
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
7

user output
7

Test 4

Verdict: ACCEPTED

input
15
2 4 2 8 6 6 5 6 4 10 9 3 10 7 ...

correct output
60

user output
60

Test 5

Verdict: ACCEPTED

input
15
3 8 6 9 1 5 1 9 3 10 1 10 9 8 ...

correct output
47

user output
47

Test 6

Verdict: ACCEPTED

input
15
2 6 4 9 8 3 8 7 1 8 8 7 5 6 8
7 6 4 9 3 8 9 5 3 10 2 2 4 6 3

correct output
46

user output
46

Test 7

Verdict: ACCEPTED

input
15
7 10 8 8 6 10 5 1 7 3 9 4 7 9 ...

correct output
56

user output
56

Test 8

Verdict: ACCEPTED

input
15
9 8 7 7 4 6 4 10 3 7 5 9 5 9 5
3 6 7 2 9 8 3 3 7 5 6 7 9 3 8

correct output
55

user output
55

Test 9

Verdict: ACCEPTED

input
15
684567283 992849846 97315816 3...

correct output
5346487014

user output
5346487014

Test 10

Verdict: ACCEPTED

input
15
220108915 735849670 3920201 84...

correct output
4369763599

user output
4369763599

Test 11

Verdict: ACCEPTED

input
15
428748595 949568430 413698361 ...

correct output
5262225140

user output
5262225140

Test 12

Verdict: ACCEPTED

input
15
310486323 634006126 326650297 ...

correct output
5825473032

user output
5825473032

Test 13

Verdict: ACCEPTED

input
15
865322099 789162758 742776009 ...

correct output
5028684388

user output
5028684388

Test 14

Verdict: ACCEPTED

input
100000
1 5 7 1 6 8 1 7 9 2 7 7 6 1 8 ...

correct output
387044

user output
387044

Test 15

Verdict: ACCEPTED

input
100000
10 6 1 4 1 8 5 4 8 10 5 8 7 5 ...

correct output
388046

user output
388046

Test 16

Verdict: ACCEPTED

input
100000
6 1 1 6 7 8 10 6 7 6 8 7 6 5 3...

correct output
387631

user output
387631

Test 17

Verdict: ACCEPTED

input
100000
9 2 5 7 5 8 5 3 4 10 5 6 10 2 ...

correct output
387600

user output
387600

Test 18

Verdict: ACCEPTED

input
100000
8 7 4 7 3 6 2 6 1 2 7 5 1 5 5 ...

correct output
387928

user output
387928

Test 19

Verdict: ACCEPTED

input
100000
329395763 605200206 806179577 ...

correct output
37487670627833

user output
37487670627833

Test 20

Verdict: ACCEPTED

input
100000
595917875 55389390 744521721 4...

correct output
37446270419509

user output
37446270419509

Test 21

Verdict: ACCEPTED

input
100000
535538034 976297510 186037641 ...

correct output
37452666188784

user output
37452666188784

Test 22

Verdict: ACCEPTED

input
100000
148256243 367924566 130727336 ...

correct output
37441139105851

user output
37441139105851

Test 23

Verdict: ACCEPTED

input
100000
434072499 230270558 578590809 ...

correct output
37528719082827

user output
37528719082827

Test 24

Verdict: ACCEPTED

input
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
375239

user output
375239

Test 25

Verdict: ACCEPTED

input
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
37477679133533

user output
37477679133533

Test 26

Verdict: ACCEPTED

input
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
375514

user output
375514

Test 27

Verdict: ACCEPTED

input
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
37505905982098

user output
37505905982098

Test 28

Verdict: ACCEPTED

input
100000
100000 100000 100000 100000 10...

correct output
5000000000

user output
5000000000

Test 29

Verdict: ACCEPTED

input
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
2500000000

user output
2500000000

Test 30

Verdict: ACCEPTED

input
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

correct output
3750025000

user output
3750025000