Skip to content

Instantly share code, notes, and snippets.

@morkev
Created May 8, 2024 07:09
Show Gist options
  • Select an option

  • Save morkev/cce07e1a09f8e2c9c3cfd4ec8dae68e0 to your computer and use it in GitHub Desktop.

Select an option

Save morkev/cce07e1a09f8e2c9c3cfd4ec8dae68e0 to your computer and use it in GitHub Desktop.
2017 China Collegiate Programming Contest Final (CCPC-Final 2017)
// 2017 China Collegiate Programming Contest Final (CCPC-Final 2017), problem: (E) Evil Forest.
// This was asked some time ago in an interview - might be relevant to someone, idk.
#include <iostream>
using namespace std;
#define for_each_case(i, num_cases) for (int i = 1; i <= num_cases; i++)
#define left_child_index(x) (x << 1)
#define right_child_index(x) (x << 1 | 1)
#define long_long long long
const int MAX_FORESTS = 1e3 + 10;
int forest[MAX_FORESTS];
int main() {
int num_cases;
cin >> num_cases;
int case_number = 1;
while (num_cases--) {
int num_trees;
cin >> num_trees;
long_long total_damage = 0;
for_each_case(i, num_trees) {
long_long damage;
cin >> damage;
total_damage += damage + damage / 10;
if (damage % 10 != 0)
total_damage++;
}
cout << "Case #" << case_number << ": " << total_damage << endl;
case_number++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment