← Real problems

coci21c1p1

easysimulationStatement on DMOJ

CP Lang

12 lines0.3 spec
// coci21c1p1 Ljestvica: each basket is worth 100, or 150 when the same player scored within the
// last 10 seconds. Players 1..=4 are team A, 5..=8 team B.
let n = read<1..=1_000>()
enum Team: Home, Away
domain Player = 1..=8
var last: [Player]?Int = None
var score: [Team]Int = 0
for (t, x, _) in read<[n](Int, Player, Int)>():
    let points = if last[x].is_some_and(l => t - l <= 10): 150 else: 100
    last[x] = t
    score[if x <= 4: Team.Home else: Team.Away] += points
print(score)

Accepted C++

69 lines · 0.04 s on the judge
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
	cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
	cerr << t << " | ";
	dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                           \
	cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
		 << ": ";                                          \
	dbgh(__VA_ARGS__)
#else
#define cerr   \
	if (false) \
	cerr
#define dbg(...) 1412
#endif

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

void solve() {
	int last[10];
	fill(begin(last), end(last), -1e9);
	int n;
	cin >> n;
	int a = 0, b = 0;
	while(n--) {
		int t, x, y;
		cin >> t >> x >> y;
		int points = 100;
		if (t - last[x] <= 10) {
			points = 150;
		}
		last[x] = t;
		if (x <= 4) {
			a += points;
		} else {
			b += points;
		}
	}
	cout << a << " " << b << endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cin.exceptions(ios::failbit);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int t = 1;
	// cin >> t;
	for (int _ = 1; _ <= t; _++) {
		dbg(_);
		// cout << "Case #" << _ << ": ";
		solve();
	}
}