This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
以前に作ったbs4による読み込みスクリプト。現状だと見出しだけを吐く。 | |
これを改善して一日あたりの概況記事の集合をファイル群として作ろうと思うが、 | |
あまりにもnml parsingの効率が悪くつらい気持ちとなる。 | |
""" | |
from bs4 import BeautifulSoup | |
import re | |
import numpy as np | |
import glob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input()) | |
A = [int(x) for x in input().split()] | |
MIN,MAX = min(A),max(A) | |
cost = 0 | |
for i in range(MIN,MAX+1): | |
c = 0 | |
for a in A: | |
c += (i - a)*(i - a) | |
cost = min(cost,c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nums = [int(x) for x in input().split()] | |
N,K = nums[0],nums[1] | |
D = set([int(x) for x in input().split()]) | |
ans = N | |
def solve(M): | |
M = [int(x) for x in str(M)] | |
for m in M: | |
if m in D: return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input()) | |
A = [(int(x),i+1) for i,x in zip(range(N),input().split())] | |
A.sort(reverse=True) | |
[print(x[1]) for x in A] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input()) | |
A = [int(x) for x in input().split()] | |
C = [0 for i in range(N)] | |
C[1] = A[1] - A[0] | |
for i in range(N-2): | |
C[i+2] = min( | |
C[i]+abs(A[i+2]-A[i]), | |
C[i+1]+abs(A[i+2]-A[i+1]) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
thanks to http://abc039.contest.atcoder.jp/submissions/761908 | |
""" | |
st = input().rstrip() | |
ans = ["Do","Do","Re","Re","Mi","Fa","Fa","So","So","La","La","Si"] | |
wb = "WBWBWWBWBWBW" * 5 | |
print(ans[wb.find(dy)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input()) | |
A = [int(x) for x in input().split()] | |
t = 0 | |
ans = 0 | |
for i in range(N): | |
if i == 0 or A[i-1] < A[i]: | |
t += 1 | |
else: | |
ans += t*(t+1)//2 | |
t = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------ | |
// C++ templete | |
//------------------------------------------ | |
#include <bits/stdc++.h> | |
#define int long long | |
using namespace std; | |
//typedef | |
//------------------------------------------ | |
typedef pair<int, int> PII; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------ | |
// C++ templete | |
//------------------------------------------ | |
#include <bits/stdc++.h> | |
#define int long long | |
using namespace std; | |
//typedef | |
//------------------------------------------ | |
typedef pair<int, int> PII; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nums = [int(x) for x in input().split()] | |
N,M = nums[0],nums[1] | |
imos = [0 for i in range(N+1)] | |
V = 0 | |
for i in range(M): | |
nums = [int(x) for x in input().split()] | |
a,b = nums[0]-1,nums[1]-1 | |
imos[a] += 1 | |
imos[b+1] -= 1 | |