牛客网代码

From Mature Bird, 4 Years ago, written in C++, viewed 467 times.
URL http://axuhongbo.top/paste/view/2eeec198 Embed
Download Paste or View Raw
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. int n,m;
  5. int a[200],b[200],c[200],d[200];
  6. int main()
  7. {
  8.      cin>>n>>m;
  9.      double ans = -0x3f3f3f3f,sum = 0,sum2 =0 ;
  10.      for(int i=1;i<=n;i++)
  11.      {
  12.          cin>>a[i]>>d[i];
  13.          if(d[i]==1)
  14.          {
  15.              sum+=a[i]*0.8;
  16.          }
  17.         else sum+=a[i];
  18.          sum2+=a[i];
  19.      }
  20.      for(int i=1;i<=m;i++)
  21.      {
  22.  
  23.          cin>>c[i]>>d[i];
  24.          if(sum2>=c[i])
  25.          {
  26.              sum = min(sum,sum2-d[i]);
  27.          }
  28.      }
  29.      cout<<fixed<<setprecision(2)<<sum<<endl;
  30.  
  31.     return 0;
  32. }
  33.  

Reply to "牛客网代码"

Here you can reply to the paste above

captcha