AtCoder Grand Contest 003

Submission #4240686

Source codeソースコード

import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
a = [ni() for _ in range(n)]

cnt = {i+1: ai for i, ai in enumerate(a)}

prev = -100
cur = 0
ans = 0
for key in sorted(cnt.keys()):
    if cnt[key] == 0:
        continue
    
    if prev == -100:
        prev = key
    
    if (key-prev) < 2:
        cur += cnt[key]
    else:
        cur = cnt[key]
        
    ans += cur // 2
    cur -= 2 * (cur//2)
    
    prev = key
        
print(ans)

Submission

Task問題 B - Simplified mahjong
User nameユーザ名 polarbear08
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 400
Source lengthソースコード長 874 Byte
File nameファイル名
Exec time実行時間 164 ms
Memory usageメモリ使用量 19100 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt
All 400 / 400 01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,11.txt,12.txt,13.txt,14.txt,15.txt,16.txt,17.txt,18.txt,19.txt,20.txt,21.txt,22.txt,s1.txt,s2.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 141 ms 19100 KB
02.txt AC 152 ms 19100 KB
03.txt AC 143 ms 19084 KB
04.txt AC 111 ms 17536 KB
05.txt AC 115 ms 17428 KB
06.txt AC 113 ms 17412 KB
07.txt AC 132 ms 18452 KB
08.txt AC 132 ms 18440 KB
09.txt AC 149 ms 19092 KB
10.txt AC 144 ms 19092 KB
11.txt AC 81 ms 15864 KB
12.txt AC 155 ms 19088 KB
13.txt AC 146 ms 19084 KB
14.txt AC 144 ms 19084 KB
15.txt AC 110 ms 15896 KB
16.txt AC 164 ms 19100 KB
17.txt AC 147 ms 19100 KB
18.txt AC 17 ms 3064 KB
19.txt AC 17 ms 3064 KB
20.txt AC 17 ms 3064 KB
21.txt AC 17 ms 3064 KB
22.txt AC 17 ms 3064 KB
s1.txt AC 17 ms 3064 KB
s2.txt AC 17 ms 3064 KB