Codeforce 588A - Duff and Meat (贪心)
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <vector> 6 #include <cstdlib> 7 #include <iomanip> 8 #include <cmath> 9 #include <ctime> 10 #include <map> 11 #include <set> 12 using namespace std; 13 #define lowbit(x) (x&(-x)) 14 #define max(x,y) (x>y?x:y) 15 #define min(x,y) (x<y?x:y) 16 #define MAX 100000000000000000 17 #define MOD 1000000007 18 #define pi acos(-1.0) 19 #define ei exp(1) 20 #define PI 3.141592653589793238462 21 #define INF 0x3f3f3f3f3f 22 #define mem(a) (memset(a,0,sizeof(a))) 23 typedef long long ll; 24 const int N=100005; 25 const int mod=1e9+7; 26 int a[N],b[N]; 27 int main() 28 { 29 int n; 30 scanf("%d",&n); 31 for(int i=0;i<n;i++){ 32 scanf("%d %d",&a[i],&b[i]); 33 } 34 ll s=0; 35 s+=a[0]*b[0]; 36 int t=b[0]; 37 for(int i=1;i<n;i++){ 38 if(b[i]<t) t=b[i]; 39 s+=a[i]*t; 40 } 41 printf("%lld\n",s); 42 return 0; 43 }