Submission #67003198
Source Code Expand
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
ans = []
for _ in range(t):
n = int(input())
c1, c2 = 0, 0
v = 0
for _ in range(n):
a, b, c = map(int, input().split())
if a + c <= b:
c1 += a
c2 += c
else:
if a <= b:
u = b - a
b, c = b - u, c - u
c2 += u
if c <= b:
u = b - c
b, a = b - u, a - u
c1 += u
v += b
if c1 > c2:
c1, c2 = c2, c1
u = min(c2 - c1, v)
c1 += u
v -= u
ans0 = c1 if c1 ^ c2 else c1 + (v >> 1)
ans.append(ans0)
sys.stdout.write("\n".join(map(str, ans)))
Submission Info
| Submission Time | |
|---|---|
| Task | A - CatCoder Double Contest |
| User | misorin |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 500 |
| Code Size | 781 Byte |
| Status | AC |
| Exec Time | 119 ms |
| Memory | 94808 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| 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 | 119 ms | 94068 KiB |
| 01-02.txt | AC | 102 ms | 93500 KiB |
| 01-03.txt | AC | 98 ms | 93292 KiB |
| 01-04.txt | AC | 101 ms | 93000 KiB |
| 01-05.txt | AC | 108 ms | 93852 KiB |
| 02-01.txt | AC | 92 ms | 93932 KiB |
| 02-02.txt | AC | 92 ms | 93940 KiB |
| 02-03.txt | AC | 92 ms | 94160 KiB |
| 02-04.txt | AC | 87 ms | 90968 KiB |
| 02-05.txt | AC | 87 ms | 91064 KiB |
| 02-06.txt | AC | 86 ms | 91020 KiB |
| 03-01.txt | AC | 85 ms | 94808 KiB |
| sample-01.txt | AC | 53 ms | 76652 KiB |