Codeforces 暑期特訓:我想成為演算法大師 - NYCU 2025 Team Selection Programming Contest - Week 9
Luke 我什麼都不會

National Yang Ming Chiao Tung University 2025 Team Selection Programming Contest

K. Karl’s Dormitory Allocation

Problem: K. Karl’s Dormitory Allocation

Solution: GitHub Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import math

n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)

a = arr[m-1]
b = arr[m]
# print(a, b)
v = (a + b) / 2
total = m * v

e = total / n
pay = v - e

# print(pay, e)
p = math.floor(pay)
q = math.ceil(e)
# print(p, q)


r = abs(m * p - (n-m)*q)
print(p, q, r)

L. Lantern Festival

Problem: L. Lantern Festival

Solution: GitHub Code

1
2
3
4
5
6
7
8
9
10
11
12
13
void solve(){
int n;
cin >> n;

int x;
int ans = 0;
for(int i=0; i<n; i++){
cin >> x;
if(x==1) ans++;
}

cout << ans << endl;
}
Powered by Hexo & Theme Keep