ABC055C-python
n,m=map(int, input().split())
if(n >= m//2):
print(m//2)
else:
result=n + (m-2*n)//4
print(result)
ABC149B-python
a, b, k=map(int, input().split())
if(a >=k):
print(a-k, b)
else:
c= b-(k-a) if b-(k-a) >= 0 else 0
print(0, c)
AGC029A-python
- n=input()
- l=[]
- i=0
- while True:
- try:
- char_index = n.index('W', i, len(n))
- l.append(char_index + 1)
- i= char_index + 1
- except:
- break
- sum=0
- for j in range(1,len(l)+1):
- sum += (l[j-1]-j)
- print(sum)
最終的にi個のWのインデックスは0,1...i-1となる。
また、Wをiからjに移動するためには(j-i)回の移動が必要
ABC251B-python
n,w=map(int, input().split())
s=set()
l=list(map(int, input().split()))
l.insert(0,0)
l.insert(0,0)
a=len(l)
for i in range(a):
for j in range(i+1, a):
for k in range(j+1,a):
b=l[i]+l[j]+l[k]
if b <= w:
s.add(b)
print(len(s))
愚直に数え上げるならforループの塊3ついる...?と思ったが、A1~Anの前に0,0置くことで1つのおもり・2つのおもりのパターンもケアできることに気づいたエライ
ABC165D-pythonを解きたかった
公式解説に記載されてた
f(x+B)=f(x)が分からなかったの悔しいい
リベンジする
ABC053C-python
n=int(input())
amari=n%11
s=n//11
if amari == 0:
print(2*s)
elif amari <= 6:
print(2*s+1)
else:
print(2*s+2)
6,5,6,5...と回すのが最短
n÷11のあまりに応じて余分に動かす回数を調節
ABC065B-python
n=int(input())
l=[0]
for i in range(n):
l.append(int(input()))
count=0
botton=1
for i in range(n):
botton=l[botton]
count += 1
if botton == 2:
break
if botton == 2:
print(count)
else:
print(-1)
i=a[i]みたいな問題、よく見かけるけど自分で1からコーディングするのは初めてだったので存外苦労した。