need python day 1, worrying
This commit is contained in:
		
							
								
								
									
										21
									
								
								d01/run.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								d01/run.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
import sys, os
 | 
			
		||||
from collections import Counter
 | 
			
		||||
 | 
			
		||||
L1 = []
 | 
			
		||||
L2 = []
 | 
			
		||||
L = sys.stdin.readlines()
 | 
			
		||||
for l in L:
 | 
			
		||||
    [a,b] = l[:-1].split("   ")
 | 
			
		||||
    L1.append(int(a))
 | 
			
		||||
    L2.append(int(b))
 | 
			
		||||
 | 
			
		||||
S = 0
 | 
			
		||||
for a, b in zip(sorted(L1), sorted(L2)):
 | 
			
		||||
    S += abs(b-a)
 | 
			
		||||
print("1:", S)
 | 
			
		||||
 | 
			
		||||
C2 = Counter(L2)
 | 
			
		||||
S=0
 | 
			
		||||
for n in L1:
 | 
			
		||||
   S += n * C2[n]
 | 
			
		||||
print("2:", S) 
 | 
			
		||||
		Reference in New Issue
	
	Block a user