題目
原題鏈接:A. Duff and Meat
題意
每天要買a斤肉刹淌,每斤p元,今天可以為后幾天買讥耗,問最少花多錢有勾。
代碼
#include<bits/stdc++.h>
using namespace std;
int main() {
int n,a,p,count=0,low;
scanf("%d",&n);
scanf("%d%d",&a,&p);
count+=a*p;
low=p;
n--;
while(n--){
scanf("%d%d",&a,&p);
if(p<low){//若當(dāng)天價格比以往價格低,則按這個價格買古程,否則按以往價格買
low=p;
count+=a*p;
}else{
count+=a*low;
}
}
printf("%d\n",count);
return 0;
}