結果
問題 | No.5020 Averaging |
ユーザー | kumk |
提出日時 | 2024-02-25 16:11:24 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 337 ms / 1,000 ms |
コード長 | 2,874 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 80,260 KB |
スコア | 24,152,245 |
最終ジャッジ日時 | 2024-02-25 16:11:59 |
合計ジャッジ時間 | 18,084 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 287 ms
79,764 KB |
testcase_01 | AC | 332 ms
79,248 KB |
testcase_02 | AC | 337 ms
79,512 KB |
testcase_03 | AC | 293 ms
78,864 KB |
testcase_04 | AC | 296 ms
79,120 KB |
testcase_05 | AC | 290 ms
78,608 KB |
testcase_06 | AC | 336 ms
79,768 KB |
testcase_07 | AC | 310 ms
80,260 KB |
testcase_08 | AC | 307 ms
79,000 KB |
testcase_09 | AC | 302 ms
79,256 KB |
testcase_10 | AC | 305 ms
78,996 KB |
testcase_11 | AC | 291 ms
79,000 KB |
testcase_12 | AC | 290 ms
78,480 KB |
testcase_13 | AC | 281 ms
78,608 KB |
testcase_14 | AC | 316 ms
79,248 KB |
testcase_15 | AC | 323 ms
79,244 KB |
testcase_16 | AC | 293 ms
79,008 KB |
testcase_17 | AC | 286 ms
78,480 KB |
testcase_18 | AC | 309 ms
79,512 KB |
testcase_19 | AC | 298 ms
80,144 KB |
testcase_20 | AC | 321 ms
79,228 KB |
testcase_21 | AC | 313 ms
79,644 KB |
testcase_22 | AC | 328 ms
79,632 KB |
testcase_23 | AC | 295 ms
79,000 KB |
testcase_24 | AC | 280 ms
79,244 KB |
testcase_25 | AC | 316 ms
79,628 KB |
testcase_26 | AC | 318 ms
79,372 KB |
testcase_27 | AC | 303 ms
78,992 KB |
testcase_28 | AC | 317 ms
79,128 KB |
testcase_29 | AC | 270 ms
79,248 KB |
testcase_30 | AC | 311 ms
78,996 KB |
testcase_31 | AC | 288 ms
79,128 KB |
testcase_32 | AC | 287 ms
78,864 KB |
testcase_33 | AC | 287 ms
79,504 KB |
testcase_34 | AC | 287 ms
79,116 KB |
testcase_35 | AC | 288 ms
79,244 KB |
testcase_36 | AC | 284 ms
78,488 KB |
testcase_37 | AC | 275 ms
80,144 KB |
testcase_38 | AC | 294 ms
79,248 KB |
testcase_39 | AC | 292 ms
79,636 KB |
testcase_40 | AC | 315 ms
79,116 KB |
testcase_41 | AC | 272 ms
78,476 KB |
testcase_42 | AC | 305 ms
78,988 KB |
testcase_43 | AC | 292 ms
79,012 KB |
testcase_44 | AC | 316 ms
79,256 KB |
testcase_45 | AC | 302 ms
79,512 KB |
testcase_46 | AC | 297 ms
79,128 KB |
testcase_47 | AC | 302 ms
79,112 KB |
testcase_48 | AC | 291 ms
79,244 KB |
testcase_49 | AC | 296 ms
78,988 KB |
ソースコード
import sys import math import io import sys import random TARGET = 500000000000000000 random.seed(18) def cal_score(v1, v2, isDisplay = False): error1 = abs(v1-TARGET) error2 = abs(v2-TARGET) sa = max(error1,error2) #score = int(2 * 10**6 - 10**5 * math.log10(sa +1.0)) score = (int)(2000000.0 - 100000.0 * math.log10(1.0 * max(error1, error2) + 1.0)) if isDisplay: print(TARGET,v1,v2) print(error1,error2,score) return score def cal_temp_score(v1, v2, isDisplay = False): error1 = abs(v1-TARGET) error2 = abs(v2-TARGET) score = - error1 - error2 if isDisplay: print(error1,error2,score) return score def cal_ave(A,B, i,j): aveA,aveB = (A[i] + A[j])//2, (B[i] + B[j])//2 # print(i,j,A[i],A[j],aveA,B[i],B[j],aveB) A[i] = aveA A[j] = aveA B[i] = aveB B[j] = aveB # print("after", i,j,A[i],A[j],aveA,B[i],B[j],aveB) def save(A, B, i,j): return (i,j,A[i],B[i],A[j],B[j]) def restore(A, B, save): i,j = save[0], save[1] A[i],B[i],A[j],B[j] = save[2],save[3],save[4],save[5] def main(): args = sys.argv debug = False if len(args) >= 2: debug = True sys.setrecursionlimit(10000000) #H=int(input()) #A=list(map(int,input().split())) #A,B=map(int,input().split()) #A,B=input().split() #B = [list(map(int,input().split())) for _ in range(N)] # 入力 N = int(input()) A = [0] * (N +1) B = [0] * (N +1) for i in range(1,N+1): A[i], B[i] = map(int, input().split()) MAX_SOUSA = 50 TEMP_ITER = -1 # 出力 print(MAX_SOUSA) it = 0 for it in range(MAX_SOUSA): now_score = cal_score(A[1],B[1]) kouho = (1,1) for i in range(2, N + 1): save_info = save(A,B,1,i) cal_ave(A,B,1,i) score = cal_score(A[1],B[1]) restore(A,B,save_info) if now_score < score: kouho = (1,i) now_score = score if kouho[1] ==1: kouho_list = [] for k in range(2, N+1): for l in range(2, N+1): if l >= k: continue score = cal_score(A[k],B[l]) save_info = save(A,B,k,l) cal_ave(A,B,k,l) after_score = cal_score(A[k],B[l]) if after_score > score: kouho_list.append((after_score,(k,l))) restore(A,B,save_info) kouho_list.sort(reverse=True) kouho = kouho_list[0][1] cal_ave(A,B,kouho[0],kouho[1]) print(f"{kouho[0]} {kouho[1]}") if debug: print(it, "score") cal_score(A[1],B[1], True) if __name__ == "__main__": main()