aboutsummaryrefslogtreecommitdiff
path: root/2024/01/day01b.cpp
blob: 91ef0db31aa515a7ed58d6c5eae82ab7b8973927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int x, y, tot;
	vector<int> v, w;

	while (cin >> x >> y) {
		v.push_back(x);
		w.push_back(y);
	}

	tot = 0;
	for (unsigned i = 0; i < v.size(); i++)
		tot += v[i] * count(w.begin(), w.end(), v[i]);

	cout << tot << endl;
	return 0;
}

Generated with cgit - Back to sebastiano.tronto.net