#34327: 用for暴力解


yp11151208@yphs.tp.edu.tw (805-42葉宏湧)

學校 : 臺北市私立延平高級中學
編號 : 197051
來源 : [203.72.178.1]
最後登入時間 :
2023-09-24 09:29:19
f071. 2. 刮刮樂 (Lottery) -- 2020年5月TOI練習賽新手組 | From: [39.12.9.25] | 發表日期 : 2023-03-10 19:22

#include<bits/stdc++.h>
using namespace std;
main(){
    int a[3],i,j,r[5],s[5],t=0;
    cin>>a[0]>>a[1]>>a[2];
    for(i=0;i<5;i++) cin>>r[i];
    for(i=0;i<5;i++) cin>>s[i];
    for(i=0;i<2;i++) for(j=0;j<5;j++) if(a[i]==r[j]) t+=s[j];
    j=1;
    for(i=0;i<5;i++) if(a[2]==r[i]){t-=s[i]; j=0;}
    if(j) t*=2;
    if(t<0) t=0;
    cout<<t<<endl;
}

 
ZeroJudge Forum