結果
問題 | No.1837 Same but Different |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:54:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,668 bytes |
コンパイル時間 | 411 ms |
コンパイル使用メモリ | 82,532 KB |
実行使用メモリ | 62,188 KB |
最終ジャッジ日時 | 2025-03-26 15:55:50 |
合計ジャッジ時間 | 5,143 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 WA * 20 |
ソースコード
n = int(input())if n == 3:print("99 824 4353")print("0 1 5275")else:# Construct AA = [99, 824, 4353]current = 4354for _ in range(3, n):A.append(current)current += 1sum_A = sum(A)# Construct BB = [0, 1]remaining = n - 2sum_remaining = sum_A - 1 # since B starts with 0 and 1# Calculate K for the remaining elementsm = remainingif m == 1:# Only one element neededB.append(sum_remaining)else:# Solve for K in arithmetic sequence# sum = m*K + (m-1)*m//2# K = (sum_remaining - (m-1)*m//2) // mtotal_needed = sum_remainingK = (total_needed - (m-1)*m//2) // m# Ensure K is sufficiently large to avoid overlaps# For safety, start from a large baseK = max(K, 10**5)elements = []current_sum = K * m + (m-1)*m//2if current_sum > total_needed:# Adjust KK = (total_needed - (m-1)*m//2) // mcurrent_sum = K * m + (m-1)*m//2# Generate the elementselements = list(range(K, K + m))current_sum = sum(elements)if current_sum < total_needed:elements[-1] += total_needed - current_sumelif current_sum > total_needed:# This shouldn't happen with proper K calculationpassB.extend(elements)# Verify B is strictly increasing and within 0-10000# In case elements are exceeding 10000, adjust (but per problem statement, it's guaranteed)# Outputprint(' '.join(map(str, A)))print(' '.join(map(str, B)))