标签:-- 解决 pac end ios std bool 符号 str
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool cmp(int a, int b){
return a > b;
}
int main(){
int Nc, Np;
int sum = 0;
int p = 0, q = 0;
scanf("%d", &Nc);
vector<int> coupon(Nc);
for(int i = 0; i < Nc; i++){
scanf("%d", &coupon[i]);
}
scanf("%d", &Np);
vector<int> product(Np);
for(int i = 0; i < Np; i++){
scanf("%d", &product[i]);
}
sort(coupon.begin(), coupon.end(), cmp);
sort(product.begin(), product.end(), cmp);
while(q < Nc && p < Np && coupon[q] > 0 && product[p] > 0){
sum += coupon[q] * product[p];
q++; p++;
}
q = Nc - 1, p = Np - 1;
while(p >= 0 && q >= 0 && coupon[q] < 0 && product[p] < 0){
sum += coupon[q] * product[p];
q--; p--;
}
printf("%d", sum);
return 0;
}
标签:-- 解决 pac end ios std bool 符号 str
原文地址:https://www.cnblogs.com/tsruixi/p/11849959.html