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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:18: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
#define C 15133

using namespace std;

int main () {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin>>n>>k;
  ll ans = 0;
  vector<pair<int, int>> v(n);
  vector<int> w(k);
  for (int i; i <n; i++) {
    cin>>v[i].second>>v[i].first;
  }
  for (int i = 0; i < k; i++) {
   cin>>w[i];
  }
  sort(w.begin(), w.end());
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < n; 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: ACCEPTED

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

correct output
1392413902

user output
1392413902

Test 9

Verdict: ACCEPTED

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

correct output
1695

user output
1695

Test 10

Verdict: ACCEPTED

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

correct output
10022686883

user output
10022686883

Test 11

Verdict: ACCEPTED

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

correct output
19941

user output
19941

Test 12

Verdict:

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

correct output
285052149031

user output
(empty)