Risk Rolls
Memory limit: 256 MB
Alena and Boris are playing Risk today. We‘ll call an outcome the sum of values on the faces of 111 or more rolled dice. Alena has NNN possible outcomes whilst Boris has MMM. In turns, each one of them will choose their best possible available outcome and play it. If Alena‘s outcome is strictly greater than Boris‘s, then Alena wins; otherwise Boris wins. Whenever one of them runs out of outcomes, the game ends.
In how many turns does Alena win? What about Boris?
Standard input
The first line contains two integers NNN and MMM.
The second contains NNN integers, Alena‘s possible outcomes.
The third line contains MMM integers, Boris‘s possible outcomes.
Standard output
Print two integers AAA and BBB on the first line of the output; AAA represents the number of turns won by Alena and BBB the number of turns won by Boris.
Constraints and notes
- 1≤N,M≤101 \leq N, M \leq 101≤N,M≤10
- 1≤v≤241 \leq v \leq 241≤v≤24, where vvv is a possible outcome value
Input | Output | Explanation |
---|---|---|
1 3 24 1 2 3 |
1 0 |
In the first turn, Alena will play 242424, which will beat Boris‘s 333 |
3 1 2 1 3 24 |
0 1 |
This is the first sample with reversed outcomes for Alena and Boris. |
2 2 10 1 5 5 |
1 1 |
|
4 3 3 4 5 24 9 9 9 |
1 2 |
In the first turn Alena will beat Boris because she will play 242424. |
3 3 8 9 10 10 8 8 |
1 2 |
In the first turn they will play 101010 against 101010 and Boris will win. On the second turn they will play 999 versus 888 and Alena will win. The third turn is also won by Boris. |
直接做就好了,排序,注意有个strictly就是大于
#include <bits/stdc++.h> using namespace std; int a[15],b[15]; int cmp(int a,int b) { return a>b; } int main() { int n,m; cin>>n>>m; int mi=min(n,m); for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<m;i++) cin>>b[i]; sort(a,a+n,cmp); sort(b,b+n,cmp); int af=0,bf=0; for(int i=0;i<mi;i++) if(a[i]>b[i])af++; else bf++; cout<<af<<" "<<bf; return 0; }