Sicily 1093. Air Express

来源:互联网 发布:微信一夜暴富软件 编辑:程序博客网 时间:2024/05/19 19:40
#include <iostream>using namespace std;int arr[1000000];int main(){int n1,p1,n2,p2,n3,p3,p4,k=1;while(cin >> n1){cin >> p1 >> n2 >> p2 >> n3 >> p3 >> p4;int n=0;while(true){cin >> arr[n];if(arr[n]==0)break;else n++;}cout << "Set number " << k << ":" << endl;k++;for(int i=0; i < n; ++i){int price1=0,price2=0;if(arr[i] <= n1 && arr[i]>= 0){price1=arr[i]*p1;price2=(n1+1)*p2;if(price1 <= price2) cout << "Weight (" << arr[i] << ") has best price $" << price1 <<  " (add 0 pounds)" << endl;else cout << "Weight (" << arr[i] << ") has best price $" << price2 <<  " (add " << n1+1-arr[i] << " pounds)" << endl;}else if(arr[i] <= n2 && arr[i]>= n1+1){price1=arr[i]*p2;price2=(n2+1)*p3;if(price1 <= price2) cout << "Weight (" << arr[i] << ") has best price $" << price1 <<  " (add 0 pounds)" << endl;else cout << "Weight (" << arr[i] << ") has best price $" << price2 <<  " (add " << n2+1-arr[i] << " pounds)" << endl;}else if(arr[i] <=n3 && arr[i] >= n2+1){price1=arr[i]*p3;price2=(n3+1)*p4;if(price1 <= price2) cout << "Weight (" << arr[i] << ") has best price $" << price1 <<  " (add 0 pounds)" << endl;else cout << "Weight (" << arr[i] << ") has best price $" << price2 <<  " (add " << n3+1-arr[i] << " pounds)" << endl;}else if(arr[i] >= n3+1) cout << "Weight (" << arr[i] << ") has best price $" << p4*arr[i] <<  " (add 0 pounds)" << endl;}cout << endl;}}

0 0