zoukankan      html  css  js  c++  java
  • Duff and Meat

    题目大意:有一个人他有每天需要吃ai千克肉,并且当天肉的价格是pi,问N天后他至少需要花费多少钱买肉。

    分析:注意一下,他是可以提前买好肉放着的。

    代码如下:


    #include<iostream>
    #include<string.h>
    #include<stdio.h>
    #include<algorithm>
    #include<math.h>
    using namespace std;
    
    const int MAXN = 17;
    const int oo = 1e9+7;
    
    int main()
    {
        int N;
    
        while(scanf("%d", &N) != EOF)
        {
            int ai, pi, ans=0, MinP=oo;
    
            while(N--)
            {
                scanf("%d%d", &ai, &pi);
                MinP = min(MinP, pi);
                ans += ai * MinP;
            }
    
            printf("%d
    ", ans);
        }
    
        return 0;
    }
  • 相关阅读:
    树状数组&线段树
    8月7日小练
    8月6日小练
    LID&LDS 的另外一种算法
    LCS,LIS,LCIS
    8-11-Exercise
    8-10-Exercise
    线段树
    8-7-Exercise
    8-6-Exercise
  • 原文地址:https://www.cnblogs.com/liuxin13/p/4915141.html
Copyright © 2011-2022 走看看