Skip to content

Commit c5e561e

Browse files
committed
tco 04 round 4 500 sol
1 parent 8cd35e7 commit c5e561e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

HeatDeath.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ class HeatDeath{
2424
bool done = false;
2525
for(int i = 0; i+1 < n; i++)
2626
if(e[i+1]-e[i] >= 2){
27-
t++;
28-
e[i]++;
29-
e[i+1]--;
27+
int m1 = (e[i+1]+e[i])/2, m2 = (e[i+1]+e[i]+1)/2;
28+
t += (m1-e[i]);
29+
e[i] = m1;
30+
e[i+1] = m2;
3031
done = true;
3132
i = n;
3233
}

0 commit comments

Comments
 (0)