Skip to content

Instantly share code, notes, and snippets.

@deviantfero
Last active May 19, 2018 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviantfero/c340e96ba9a886324a1b868cca2208c0 to your computer and use it in GitHub Desktop.
Save deviantfero/c340e96ba9a886324a1b868cca2208c0 to your computer and use it in GitHub Desktop.
solution to problem 10300 in C++
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
int area, friendliness, animals;
int tests, farmers, aux = 0;
std::vector<int> debt;
std::cin >> tests;
for(; tests > 0; tests--, aux = 0) {
std::cin >> farmers;
for(; farmers > 0; farmers--) {
std::cin >> area >> animals >> friendliness;
aux += area * friendliness;
}
debt.push_back(aux);
}
std::for_each(debt.begin(), debt.end(), [](auto d) { std::cout << d << "\n"; });
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment