結果
| 問題 | 
                            No.1373 Directed Operations
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 17:01:25 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,157 bytes | 
| コンパイル時間 | 388 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 223,488 KB | 
| 最終ジャッジ日時 | 2025-06-12 17:01:30 | 
| 合計ジャッジ時間 | 4,441 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | TLE * 1 -- * 18 | 
ソースコード
def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    a_list = list(map(int, input[idx:idx + N-1]))
    
    reachable = {1}
    x_choices = []
    
    for a in a_list:
        max_x = N - a
        if max_x < 1:
            print("NO")
            return
        
        sorted_reachable = sorted(reachable)
        found = False
        for x in sorted_reachable:
            if x > max_x:
                break
            new_node = x + a
            if new_node not in reachable:
                x_choices.append(x)
                reachable.add(new_node)
                found = True
                break
        
        if not found:
            if sorted_reachable[0] > max_x:
                print("NO")
                return
            x = sorted_reachable[0]
            new_node = x + a
            x_choices.append(x)
            if new_node not in reachable:
                reachable.add(new_node)
    
    if len(reachable) != N:
        print("NO")
    else:
        print("YES")
        for x in x_choices:
            print(x)
    
if __name__ == "__main__":
    main()
            
            
            
        
            
gew1fw