题解 | 小红的优惠券

小红的优惠券

https://www.nowcoder.com/practice/e991a011f96444f3a6ad57943d39f4ad

#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

struct discount {
    int aj;
    int bj;
};


int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    discount* a = new discount[m];
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d",&a[i].aj, &a[i].bj);
    }
    int max = -1;
    for(int i = 0; i < m; i++)
    {
        if(a[i].aj <= n && a[i].bj > max )
            max = a[i].bj;
    }
    if(max == -1)
        printf("%d",n);
    else
        printf("%d",n-max);
    return 0;
}

全部评论

相关推荐

林后润:听说他们有kpi,要到了简历编号就不理人了
27届求职交流
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务