Codeforces Round #445 (Div. 2, based on Technocup 2018 Elimination Round 3)
A. ACM ICPC
题意
问你能否把6个人按照分数平均分成2支队
题解
暴力看有没有3个人的分数加起来正好一半
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 a = [] 2 sum = 0 3 line = input().split() 4 for i in range(6): 5 a.append(int(line[i])) 6 sum += a[i] 7 pass 8 half = sum // 2 9 if sum != half * 2: 10 print('NO') 11 pass 12 else: 13 ok = 0 14 for i in range(6): 15 for j in range(i + 1, 6): 16 for k in range(j + 1, 6): 17 if a[i] + a[j] + a[k] == half: 18 ok = 1 19 pass 20 continue 21 continue 22 continue 23 if ok == 1: 24 print('YES') 25 pass 26 else: 27 print('NO') 28 pass
B. Vlad and Cafes
题意
问Vlad去过的咖啡厅里, 没去时间最久的一个
题解
从后往前一个一个标记, 找到最后一个标记上的
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 vis = [0 for i in range(200005)] 2 n = int(input()) 3 a = [] 4 line = input().split() 5 for i in range(n): 6 a.append(int(line[i])) 7 pass 8 ans = 0 9 for i in range(n - 1, -1, -1): 10 if vis[a[i]] == 1: 11 continue 12 else: 13 vis[a[i]] = 1 14 ans = a[i] 15 continue 16 continue 17 print(ans)
C. Petya and Catacombs
题意
略
题解
把"当前房间"和"当前房间记录的ti时间到的房间"连起来, 形成一棵树
求这棵树的叶子结点的个数
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 n = int(input()) 2 vis = [0 for i in range(n + 1)] 3 line = input().split() 4 for i in range(n): 5 vis[int(line[i])] = 1 6 continue 7 ans = 0 8 for i in range(n + 1): 9 if vis[i] == 0: 10 ans += 1 11 continue 12 continue 13 print(ans)
D.
E.
F.