# 11009: 【原1009】二哥炒股票

### 题目描述

author: xjia 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/1009

## 题目描述

1. 佣金，收取交易额的0.2%，但最低的收取标准是5元。比如买入总金额为1000元的股票，实际佣金是2元，但不超过5元，所以按5元收取。

2. 过户费，每一千股收取1元。

3. 通讯费，由于二哥在上海，每次只收取本地交易费用1元。

## Sample Input

2
15 50 1
40 30 2
4
10 100
20 90
30 95
40 102


## Sample Output

-195928.00


## FineArtz's solution

/* 二哥炒股票 */
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

//constructor
TradeRecord() : t(0), a(0), d(0) {};
int t, a;
short d;
};

double ret = 0.0;
double outcome = 100.0 * v * trade.a;
outcome += (outcome - 2500 > -1e-6) ? outcome * 0.002 : 5.0;
outcome += 1.0;
ret -= outcome;
}
else{
double income = 100.0 * v * trade.a;
double t = income;
income -= t * 0.001;
income -= (t - 2500 > -1e-6) ? t * 0.002 : 5.0;
income -= 1.0;
ret += income;
}
return ret;
}

int main(){
int m = 0;
cin >> m;
for (int i = 1; i <= m; ++i){
cin >> tr[i].t >> tr[i].a >> tr[i].d;
}
int n = 0;
cin >> n;
int t[10005], v[10005];
for (int i = 1; i <= n; ++i)
cin >> t[i] >> v[i];
int j = 1;
double NetProfit = 0.0;
for (int i = 1; i <= n; ++i){
if (t[i] < tr[j].t) continue;
while (j <= m && tr[j].t < t[i]){
NetProfit += profit(tr[j], v[i - 1]);
++j;
}
if (j > m) break;
}
for (int i = j; i <= m; ++i){
NetProfit += profit(tr[i], v[n]);
}
cout << setiosflags(ios::fixed) << setprecision(2) << NetProfit << endl;
return 0;
}


## ligongzzz's solution

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
using namespace std;

typedef pair<int, int> pii;

class type {
public:
int t, a, d;
};

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int m, n;
cin >> m;

for (int i = 0; i < m; ++i) {
}

cin >> n;
vector<pair<int, int>> val_data(n);
for (int i = 0; i < n; ++i)
cin >> val_data[i].first >> val_data[i].second;

function<bool(const pii&,const pii&)> cmp = [](const pair<int, int>& a,const pair<int, int>& b) {
return a.first < b.first;
};

sort(val_data.begin(), val_data.end(), cmp);

double ans = 0.0;
for (int i = 0, j = 0; i < m; ++i) {
for (; j < n - 1 && buy_data[i].t >= val_data[j + 1].first; ++j);
double cur_num = 100.0 * buy_data[i].a * val_data[j].second;
ans -= cur_num * 0.002 > 5.0 ? cur_num * 0.002 : 5.0;
ans -= 1.0 * buy_data[i].a / 10;
ans -= 1.0;
ans -= cur_num;
}
else {
double cur_num = 100.0 * buy_data[i].a * val_data[j].second;
ans -= cur_num * 0.002 > 5.0 ? cur_num * 0.002 : 5.0;
ans -= 1.0 * buy_data[i].a / 10;
ans -= 1.0;
ans += cur_num;
ans -= cur_num * 0.001;
}
}

cout << fixed << setprecision(2) << ans;

return 0;
}


## yyong119's solution

#include <iostream>

#include <iomanip>

using namespace std;

int main(){

int m,n;

cin>>m;

for(int i=0;i<m;++i)

cin>>n;

int change_time[n],change_money[n];

for(int i=0;i<n;++i)

cin>>change_time[i]>>change_money[i];

int i=0,j=0,per_money;

double income=0.0;

for(;i<m;++i){

for(j=0;j<n-1;++j)

break;

income-=((per_money*0.002)>5?(per_money*0.002):5);