貪心:Codeforces Round #674 (Div. 3) E Rock, Paper, Scissors s
https://codeforces.com/problemset/problem/1426/E
求A贏的最大次數時很簡單,由於石頭剪刀布贏是一一對應的,直接對應贏法最大情況相加就行。
關鍵是求贏的最小次數,思路是分別求石頭剪刀布能贏的最小次數,然後直接相加即為答案
#include <iostream>
using namespace std;
int main()
{
long long N,ans1=0,ans2=0;
cin>>N;
int b[7];
for(int i=1;i<=6;i++){
cin>>b[i];
}
if(b[1]>b[4]+b[6])ans1+=b[1]-(b[4]+b[6]);
if(b[2]>b[5]+b[4])ans1+=b[2]-(b[5]+b[4]);
if(b[3]>b[6]+b[5])ans1+=b[3]-(b[6]+b[5]);
ans2+=min(b[1],b[5])+min(b[2],b[6])+min(b[3],b[4]);
cout<<ans1<<" "<<ans2<<endl;
return 0;
}
相關文章
- Codeforces Round 981 (Div. 3)(A~E)
- Codeforces Round 938 (Div. 3) E
- Codeforces Round 946 (Div. 3) G Money Buys Less Happiness Now(反悔貪心)APP
- Educational Codeforces Round 167 (Rated for Div. 2) D(dp,貪心)
- Codeforces Round 981 (Div. 3) 題解(A-E)
- Codeforces Round 892 (Div. 2) E
- Codeforces Round 945 (Div. 2) (A - E)
- Codeforces Round 936 (Div. 2) E
- Educational Codeforces Round 99 (Rated for Div. 2) D. Sequence and Swaps(貪心)
- Codeforces Round #846 (Div. 2) A-E
- Codeforces Round #851 (Div. 2) A-E
- Codeforces Round #537 (Div. 2)B. Average Superhero Gang Power (貪心+暴力)
- Codeforces Round 991 (Div. 3)
- Codeforces Round 981 (Div. 3)
- Codeforces Round 974 (Div. 3)
- Codeforces Round 966 (Div. 3)
- Codeforces Round 946 (Div. 3)
- Codeforces Round 962(Div. 3)
- Codeforces Round 962 (Div. 3)
- Codeforces Round 957 (Div. 3)
- Codeforces Round 916 (Div. 3)
- Codeforces Round 954 (Div. 3)
- Codeforces Round 933 (Div. 3)
- Codeforces Round 943 (Div. 3)
- Codeforces Round 950 (Div. 3)
- Codeforces Round #690 (Div. 3)
- 【CodeForces】 Codeforces Round #672 (Div. 2) B.Rock and Lever (思維&位運算)
- Codeforces Round 990 (Div. 2) 題解 (A ~ E)
- Educational Codeforces Round 168 (Rated for Div. 2) A - E
- Codeforces Round #681 (Div. 2)E題解
- 2024.11.17 Codeforces Round 988 (Div. 3)
- Codeforces Round 991 (Div. 3) A ~ G
- Codeforces Round 970 (Div. 3)A~F
- Codeforces Round 970 (Div. 3) ABCDEFGH
- Codeforces Round 966 (Div. 3) VP
- vp Educational Codeforces Round 168 (Rated for Div. 2) A - E
- Codeforces Round 976 (Div. 2) 題解(A-E)
- Educational Codeforces Round 143 (Rated for Div. 2) A-E