#include <stdio.h>
#include <map>
using namespace std;
void update(pair<int, int> &p, int r)
{
if (r == 1)
p.first++;
else
p.second++;
}
int min(pair<int, int> &p)
{
if (p.first < p.second)
return p.first;
return p.second;
}
int main(void)
{
int n;
int r, w, t;
map<int, pair<int, int>> m;
scanf("%d", &n);
while (n--)
{
scanf("%d%d%d", &r, &w, &t);
update(m[w-t], r);
}
int answer = 0;
for (auto c : m)
answer += min(c.second);
printf("%d\n", answer);
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <stdio.h> #include <map> using namespace std; void update(pair<int, int> &p, int r) { if (r == 1) p.first++; else p.second++; } int min(pair<int, int> &p) { if (p.first < p.second) return p.first; return p.second; } int main(void) { int n; int r, w, t; map<int, pair<int, int>> m; scanf("%d", &n); while (n--) { scanf("%d%d%d", &r, &w, &t); update(m[w-t], r); } int answer = 0; for (auto c : m) answer += min(c.second); printf("%d\n", answer); return 0; } |
English