Submission #67002272


Source Code Expand

#include <bits/stdc++.h>

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int t;
	std::cin >> t;
	while(t--) {
		int n;
		std::cin >> n;
		long long got[2] = {0, 0};
		long long rest = 0;
		while(n--) {
			int a, b, c;
			std::cin >> a >> b >> c;
			if(b >= a + c) {
				got[0] += a, got[1] += c;
			} else {
				got[0] += std::max(0, b - c), got[1] += std::max(0, b - a);
				rest += std::min(a, b) - std::max(0, b - c);
			}
		}
		std::cout << std::min(std::min(got[0], got[1]) + rest, (got[0] + got[1] + rest) / 2) << '\n';
	}
}

Submission Info

Submission Time
Task A - CatCoder Double Contest
User tfg
Language C++ 20 (gcc 12.2)
Score 500
Code Size 580 Byte
Status AC
Exec Time 40 ms
Memory 3600 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 1
AC × 13
Set Name Test Cases
Sample sample-01.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 03-01.txt, sample-01.txt
Case Name Status Exec Time Memory
01-01.txt AC 40 ms 3460 KiB
01-02.txt AC 32 ms 3428 KiB
01-03.txt AC 32 ms 3468 KiB
01-04.txt AC 30 ms 3412 KiB
01-05.txt AC 31 ms 3452 KiB
02-01.txt AC 31 ms 3592 KiB
02-02.txt AC 31 ms 3468 KiB
02-03.txt AC 31 ms 3284 KiB
02-04.txt AC 29 ms 3600 KiB
02-05.txt AC 29 ms 3456 KiB
02-06.txt AC 28 ms 3456 KiB
03-01.txt AC 32 ms 3388 KiB
sample-01.txt AC 1 ms 3384 KiB