2
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?

【AtCoder】ABC410 振り返り📝

Last updated at Posted at 2025-06-17

ABC410 - A

問題はこちら
い つ も の

N = int(input())
A = list(map(int,input().split()))
K = int(input())

count = 0;
for i in range(N):
    if(A[i]>=K):
        count += 1
        
print(count)

ABC410 - B

問題はこちら
[1,2,3,4,5] を 1 2 3 4 5 で出力する方法がわからずちょっと手こずった。
こんな簡単な方法があるんだね~

N,Q = map(int,input().split())
X = list(map(int,input().split()))
boxArray = [0]*(N)
ballArray = [0]*(Q)

for num in range(Q):
    if(X[num]>0):
        boxArray[X[num]-1] += 1
        ballArray[num] = X[num]
    else:
        for i in range(N):
            if(boxArray[i]==min(boxArray)):
                boxArray[i] += 1
                ballArray[num] += i+1
                break

print(*ballArray)

ABC410 - C

問題はこちら
またまたTLE~~~!!!!;;
一生懸命調べてratateとか便利なもの使ってみたのにTLEだヨ~!!
もうロジックからダメなんだろうな…

from collections import deque

N,Q = map(int,input().split())

# クエリを取得
Querry = []
for i in range(Q):
    Querry.append(list(map(int, input().split())))

# 整数列を生成
A = deque([0]*N)
for i in range(N):
    A[i] = i+1;

# 関数を定義
def type1(p,x):
    A[p-1] = x
    
def type2(p):
    print(A[p-1])
    
def type3(k):
    times = k%N
    A.rotate(-times)
    
# クエリを処理
for num in range(Q):
    thisQuerry = Querry[num]
    if (thisQuerry[0] == 1):
        type1(thisQuerry[1],thisQuerry[2])
        
    elif (thisQuerry[0] == 2):
        type2(thisQuerry[1])
        
    else:
        type3(thisQuerry[1])

今回の感想

今回C問題の解法考える中でいろんなこと知れた!

deque.rotate関数 参考

from collections import deque

deque_obj.rotate(n)

n: 回転させる要素の数。正の整数で右回転、負の整数で左回転。

スライスの数字 参考

list = [0, 10, 20, 30, 40, 50, 60]

print(list[:3])
# [0, 10, 20]

print(list[3:])
# [30, 40, 50, 60]

スライスの数字 閉区間→ [n:m) ←開区間

浅いコピーと深いコピー 参考

strlist1 = ['foo', 'bar', 'baz']
strlist2 = strlist1.copy()  # 浅いコピーの作成
strlist3 = strlist1  # intlist1とintlist3は同じリストオブジェクトを参照する

浅いコピーを変更しても元の配列は変更されない(私が普段やりたいのはこれ!)
深いコピーを変更すると元の配列も変更される

2
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
2
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?