結果
問題 | No.5020 Averaging |
ユーザー | kumk |
提出日時 | 2024-02-25 16:29:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 360 ms / 1,000 ms |
コード長 | 2,922 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 79,888 KB |
スコア | 26,767,092 |
最終ジャッジ日時 | 2024-02-25 16:29:28 |
合計ジャッジ時間 | 17,996 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 329 ms
79,124 KB |
testcase_01 | AC | 321 ms
79,112 KB |
testcase_02 | AC | 280 ms
78,476 KB |
testcase_03 | AC | 333 ms
79,112 KB |
testcase_04 | AC | 287 ms
78,860 KB |
testcase_05 | AC | 274 ms
79,244 KB |
testcase_06 | AC | 311 ms
79,624 KB |
testcase_07 | AC | 360 ms
79,620 KB |
testcase_08 | AC | 306 ms
78,996 KB |
testcase_09 | AC | 279 ms
79,248 KB |
testcase_10 | AC | 307 ms
79,632 KB |
testcase_11 | AC | 315 ms
79,500 KB |
testcase_12 | AC | 329 ms
79,116 KB |
testcase_13 | AC | 272 ms
78,984 KB |
testcase_14 | AC | 287 ms
79,372 KB |
testcase_15 | AC | 329 ms
79,496 KB |
testcase_16 | AC | 307 ms
78,484 KB |
testcase_17 | AC | 293 ms
79,124 KB |
testcase_18 | AC | 312 ms
79,368 KB |
testcase_19 | AC | 304 ms
78,984 KB |
testcase_20 | AC | 316 ms
78,984 KB |
testcase_21 | AC | 289 ms
79,124 KB |
testcase_22 | AC | 323 ms
79,624 KB |
testcase_23 | AC | 282 ms
79,252 KB |
testcase_24 | AC | 287 ms
79,240 KB |
testcase_25 | AC | 309 ms
78,856 KB |
testcase_26 | AC | 319 ms
79,240 KB |
testcase_27 | AC | 295 ms
78,984 KB |
testcase_28 | AC | 297 ms
79,888 KB |
testcase_29 | AC | 282 ms
78,860 KB |
testcase_30 | AC | 332 ms
79,888 KB |
testcase_31 | AC | 276 ms
79,628 KB |
testcase_32 | AC | 283 ms
79,244 KB |
testcase_33 | AC | 297 ms
79,240 KB |
testcase_34 | AC | 302 ms
79,116 KB |
testcase_35 | AC | 277 ms
79,372 KB |
testcase_36 | AC | 289 ms
79,380 KB |
testcase_37 | AC | 299 ms
79,112 KB |
testcase_38 | AC | 292 ms
79,752 KB |
testcase_39 | AC | 286 ms
79,120 KB |
testcase_40 | AC | 307 ms
79,628 KB |
testcase_41 | AC | 275 ms
79,112 KB |
testcase_42 | AC | 285 ms
79,244 KB |
testcase_43 | AC | 290 ms
78,740 KB |
testcase_44 | AC | 310 ms
79,504 KB |
testcase_45 | AC | 326 ms
78,984 KB |
testcase_46 | AC | 266 ms
78,604 KB |
testcase_47 | AC | 330 ms
79,368 KB |
testcase_48 | AC | 288 ms
79,244 KB |
testcase_49 | AC | 313 ms
79,112 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] + A[1])//2,(B[l] + B[1])//2) save_info = save(A,B,k,l) cal_ave(A,B,k,l) after_score = cal_score((A[k] + A[1])//2,(B[l] + B[1])//2) 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()