1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| #include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(vector<int> &a, vector<int> &b){
return a[0] >= b[0];
}
int solution(vector<vector<int>> scores) {
int answer = 1;
int w = scores[0][0] + scores[0][1];
vector<int> wanho(scores[0]);
sort(scores.begin(), scores.end(), cmp);
int max = 0;
for (vector<int> v : scores) {
if (v[0] > wanho[0] && v[1] > wanho[1])
return -1;
if (v[0] + v[1] > w && max <= v[1]){
answer++;
max = v[1];
}
}
return answer;
}
|