貪心: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 #180 (Div. 2) D. Fish Weight 貪心
- Codeforces Round 892 (Div. 2) E
- Codeforces Round 936 (Div. 2) E
- Codeforces Round 945 (Div. 2) (A - 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 #283 (Div. 2) D,E
- Codeforces Round #537 (Div. 2)B. Average Superhero Gang Power (貪心+暴力)
- Codeforces Round #690 (Div. 3)
- Codeforces Round 954 (Div. 3)
- Codeforces Round 943 (Div. 3)
- Codeforces Round 974 (Div. 3)
- Codeforces Round 981 (Div. 3)
- Codeforces Round 962(Div. 3)
- Codeforces Round 962 (Div. 3)
- Codeforces Round 957 (Div. 3)
- Codeforces Round 950 (Div. 3)
- Codeforces Round 966 (Div. 3)
- Codeforces Round 946 (Div. 3)
- Codeforces Round #681 (Div. 2)E題解
- Codeforces Round #361 (Div. 2) E 費馬小
- 【CodeForces】 Codeforces Round #672 (Div. 2) B.Rock and Lever (思維&位運算)
- Codeforces 459E Pashmak and Graph:dp + 貪心
- Codeforces Round #401 (Div. 2)(C,D,E)
- Codeforces Round #316 (Div. 2) E dp
- Codeforces Round #288 (Div. 2) A,B,C,D,E
- Codeforces Round #287 (Div. 2)A,B,C,D,E
- Codeforces Round #280 (Div. 2 A,B,C,D,E)
- Codeforces Round 976 (Div. 2) 題解(A-E)
- Educational Codeforces Round 168 (Rated for Div. 2) A - E
- Codeforces Round 970 (Div. 3)A~F
- Codeforces Round 933 (Div. 3)