赞
踩
时间限制
400 ms
内存限制
64 MB
题意:
思路 :
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
struct Node {
int x, y, v;
bool operator< (const Node &w) const {
return x != w.x ? x < w.x : y < w.y;
}
};
int n;
map<double, vector<Node>> ma;
int main() {
cin >> n;
int sum = 0;
for (int i = 0; i < n; ++ i) {
int x, y, v;
cin >> x >> y >> v;
sum += v;
ma[y * 1.0 / x].push_back({x, y, v});
}
cout << sum << ' ';
int cnt = 0;
for (auto x : ma) {
vector<Node> ve = x.second;
sort(ve.begin(), ve.end());
for (int i = 0; i < (int)ve.size(); ++ i) {
cnt ++ ;
if (ve[i].v == 1) {
int j = i;
while (j < ve.size() && ve[j].v == ve[i].v) j ++ ;
j -- ;
i = j;
}
}
}
cout << cnt;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。