aoc

My solutions for the Advent of Code
git clone https://git.tronto.net/aoc
Download | Log | Files | Refs | README

day01b.cpp (331B)


      1 #include <iostream>
      2 #include <algorithm>
      3 #include <vector>
      4 using namespace std;
      5 
      6 int main() {
      7 	int x, y, tot;
      8 	vector<int> v, w;
      9 
     10 	while (cin >> x >> y) {
     11 		v.push_back(x);
     12 		w.push_back(y);
     13 	}
     14 
     15 	tot = 0;
     16 	for (unsigned i = 0; i < v.size(); i++)
     17 		tot += v[i] * count(w.begin(), w.end(), v[i]);
     18 
     19 	cout << tot << endl;
     20 	return 0;
     21 }