0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paizaラーニングスキルチェック「C062:回転寿司のメロン」を解いてみた

Posted at

▼考え方

この問題を解くために私が考えた内容を以下に示します。

1.流れてくる皿の残りが10皿未満の場合は、新たにメロンを取ることはできないため、処理を終了します。10皿以上ある場合は、食べられない皿のネタは処理しないようにします。

▼コード

########## 処理0(準備) インプット,変数定義 ###########

T = int(input())

# count: お店に滞在している間に食べられるメロンの数を格納する変数
count = 0

i = 1

########## 処理1 メロンの数を計算、出力する処理 ###########

while i <= T:

    # neta: 流れてくる皿のネタを1つずつ格納する変数
    neta = input()

    if neta == "melon":
        count += 1

        # 考え方1.
        if T - i < 10:
            break
        else:
            for j in range(10):
                neta = input()
            i += 11
    
    else:
        i += 1

print(count)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?