CSES - Leirikisa 1 - Results
Submission details
Task:lopov
Sender:Kuha
Submission time:2016-07-27 17:05:04 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.05 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.05 sdetails
#5ACCEPTED0.06 sdetails
#6ACCEPTED0.05 sdetails
#7ACCEPTED0.11 sdetails
#8--details
#9--details
#10--details
#11--details
#12--details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:16:12: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   for (int i; i <n; i++) {
            ^

Code

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define N (1<<17)
#define M 1000000007

using namespace std;

pair<int, int> v[300001];

int main () {
  int n, k;
  cin>>n>>k;
  ll ans = 0;
  multiset<int> w;
  for (int i; i <n; i++) {
    cin>>v[i].second>>v[i].first;
  }
  for (int i = 0; i < k; i++) {
    int x;
    cin>>x;
   w.insert(x);
  }
  sort(v, v + n);
  for (int i = n - 1; i >= 0; i--) {
      auto p = lower_bound(w.begin(), w.end(), v[i].second);
      if (p != w.end()) {
	w.erase(p);
	ans += (ll)v[i].first;
      }
  }
  cout<<ans<<endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
2 1
5 10
100 100
11

correct output
10

user output
10

Test 2

Verdict: ACCEPTED

input
3 2
1 65
5 23
2 99
10
...

correct output
164

user output
164

Test 3

Verdict: ACCEPTED

input
10 10
1 1
6 5
8 12
10 20
...

correct output
285

user output
285

Test 4

Verdict: ACCEPTED

input
100 500
1 1
6 9
7 12
14 19
...

correct output
25259

user output
25259

Test 5

Verdict: ACCEPTED

input
1000 500
1 1
80 9
82 11
131 38
...

correct output
6230069

user output
6230069

Test 6

Verdict: ACCEPTED

input
1000 1010
1 1
5 4
10 9
11 13
...

correct output
638915

user output
638915

Test 7

Verdict: ACCEPTED

input
5000 1010
1 1
49 19
55 39
69 76
...

correct output
10595210

user output
10595210

Test 8

Verdict:

input
50000 20000
96851 85347
94211 6050
64627 18074
9696 84124
...

correct output
1392413902

user output
(empty)

Test 9

Verdict:

input
5000 100000
0 0
0 0
1 0
0 0
...

correct output
1695

user output
(empty)

Test 10

Verdict:

input
100000 100000
132731 63644
182246 131322
184048 16187
60133 177080
...

correct output
10022686883

user output
(empty)

Test 11

Verdict:

input
100000 100000
0 0
1 0
1 0
1 0
...

correct output
19941

user output
(empty)

Test 12

Verdict:

input
300000 300000
912449 903033
992783 981923
959318 988091
934786 912569
...

correct output
285052149031

user output
(empty)