Social Infrastructure Information Systems Division, Hitachi Programming Contest 2020 比赛人数5554 慢,比赛开始后13分钟才看到题目;深刻体验到600分题目的强大
Atcoder Hitachi Programming Contest 2020 B Nice Shopping 找最小值
总目录详见https://blog.csdn.net/mrcrack/article/details/104454762
在线测评地址https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_b

反反复复,题意读懂了。
两种物品,各买一件,花钱最少,允许动用折扣券。
第一次提交WA,再读题,找了原因,和的最大值是200000,而不是100000
修改,提交AC.
#include <cstdio>
#include <algorithm>
using namespace std;
#define maxn 100010
int a[maxn],b[maxn],c[maxn],d[maxn];
int main(){
int A,B,M,i,x,y,z,mna=200010,mnb=200010,mnd=200010;
scanf("%d%d%d",&A,&B,&M);
for(i=1;i<=A;i++)scanf("%d",&a[i]),mna=min(mna,a[i]);
for(i=1;i<=B;i++)scanf("%d",&b[i]),mnb=min(mnb,b[i]);
for(i=1;i<=M;i++){
scanf("%d%d%d",&x,&y,&z);
d[i]=a[x]+b[y]-z;
mnd=min(mnd,d[i]);
}
if(mnd<mna+mnb)printf("%d\n",mnd);
else printf("%d\n",mna+mnb);
return 0;
}
本文详细解析了AtcoderHitachi2020编程竞赛中B题NiceShopping的解题思路及代码实现。通过对比商品价格和优惠券使用情况,寻找购买两种物品的最低花费方案,最终解决了题目要求的问题。


被折叠的 条评论
为什么被折叠?



