#include <iostream> #include <iomanip> using namespace std; #define maxn 10 int main() { int n,m; cin >> n >> m ; float sum=0,sumall=0; // float a[maxn][2]; // float bc[maxn][2]; // float abc[11]; float a[maxn][2]={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; float bc[maxn][2]={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; float abc[11]={1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000}; // memset(a,0,sizeof(a)); // memset(bc,0,sizeof(bc)); // memset(abc,1000,sizeof(abc)); for(int i=0;i<=n-1;i++) { cin >> a[i][0] >> a[i][1]; sumall=sumall+a[i][0];//sumall是不选择满减的初始值 if(a[i][1]>0.5) { sum = sum+a[i][0]*0.8; } else sum = sum + a[i][0];//sum 是选择满减的最小可能值 } for(int j=0;j<=m-1;j++) { cin >> bc[j][0] >> bc[j][1]; if (sumall>=bc[j][0]) { abc[j]=sumall-bc[j][1]; } else abc[j]=sumall; } abc[10]=sum; float temp = 1000; for(int t=0;t<=10;t++) { if (temp>=abc[t]) temp=abc[t]; } cout<< fixed << setprecision(2)<<temp<<endl; //cout<< n << m <<endl; return 0; }
美团2018资格赛第一题
猜你喜欢
转载自blog.csdn.net/hexiquan123/article/details/80654046
今日推荐
周排行