“美登杯”上海市高校大学生程序设计邀请赛 (华东理工大学) I 小花梨点外卖

Description
小花梨点外卖,点了?件商品,第?件商品价值??元。现在有两种满减优惠方案:
第一种:总价值大于等于?元则优惠?元
第二种:总价值大于等于?元则优惠?元
最多选择一种满减优惠,小花梨想知道最少需要花多少钱
Input
第一行输入五个正整数?, ?, ?, ?, ?,含义如上
第二行输入?个正整数表示??
(1 ≤ ?, ?, ?, ?, ?, ?? ≤ 100, ? ≥ ?, ? ≥ ?)
Output
输出一行包含一个整数表示答案
Example
Sample Input Sample Output
5 10 5 15 10
1 2 3 4 5
5
5 20 20 30 30
1 2 3 4 5
15
5 5 5 10 5
1 2 3 4 5
10

签到题

#include <stdio.h>
#include<iostream>
#include<algorithm>
#include <string.h>
#define MAXN 10000 + 10
#define N 20
#define ll long long
using namespace std;

int main()
{
    int n,a,b,c,d;
    while(scanf("%d %d %d %d %d",&n,&a,&b,&c,&d)!=EOF)
    {
        int sum[10505]={0},f[105]={0},s=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&f[i]);
            s+=f[i];
            //f[i]+=f[i-1];
        }
        int x=s,y=s;
        if(s>=a) x=s-b;
        if(s>=c) y=s-d;
        printf("%d\n",min(x,y));
        /*int cnt=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=i;j<=n;j++)
            {
                sum[cnt++]=f[j]-f[i-1];
            }
        }
        sort(sum,sum+cnt);
        for(int i=1;i<cnt;i++)
        {
            printf("sum[%d]=%d ",i,sum[i]);
        }
        printf("\n");
        int x,y,s;
        x=upper_bound(sum,sum+cnt,a)-sum;
        y=upper_bound(sum,sum+cnt,c)-sum;
        s=min(sum[x-1]-b,sum[y-1]-c);
        printf("x=%d y=%d s=%d\n",x,y,s);
        printf("%d\n",s);*/
    }
}
/*
5 10 5 15 10
1 2 3 4 5
*/

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值