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
# http://codeforces.com/problemset/problem/431/C | |
[n, k, d] = [int(i) for i in raw_input().split(' ')] | |
dpAll = [[0 for i in range(n + 1)] for i in range(n + 1)] | |
dpNone = [[0 for i in range(n + 1)] for i in range(n + 1)] | |
for i in range(1, k + 1 if k + 1 < n + 1 else n + 1): | |
dpAll[1][i] = 1 | |
for i in range(1, d if d < n + 1 else n + 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
import bisect | |
s = raw_input() | |
nCases = int(raw_input()) | |
cases = [[int(i) for i in raw_input().split(' ')] for x in range(nCases)] | |
dp = [0] * (len(s) + 1) | |
for i in range(1, len(s)): | |
dp[i] = dp[i - 1] + 1 if s[i - 1] == s[i] else dp[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
s = raw_input() | |
minAB = len(s) + 1 | |
maxAB = -1 | |
minBA = len(s) + 1 | |
maxBA = -1 | |
for i in range(len(s) - 1): | |
if [s[i], s[i + 1]] == ['A', 'B']: | |
minAB = i if i < minAB else minAB | |
maxAB = i if i > maxAB else maxAB |
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, s] = [int(i) for i in raw_input().split(' ')] | |
def hasSolution(n, ss): | |
return (ss >= 0 and ss <= 9 * n) | |
ss = s | |
minS = ''; | |
for i in range(n): | |
for d in range(10): | |
if (i > 0 or d > 0 or (n == 1 and d == 0)) and hasSolution(n - i - 1, ss - d): |
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, a, b, c] = [int(i) for i in raw_input().split(' ')] | |
dp = [0] * (n + 1) | |
dp[0] = 0 | |
for i in range(1, n + 1): | |
dp[i] = max( | |
dp[i - a] if i - a >= 0 else -4001, | |
dp[i - b] if i - b >= 0 else -4001, | |
dp[i - c] if i - c >= 0 else -4001 |
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
nBoys = int(raw_input()) | |
aBoys = [int(i) for i in raw_input().split(' ')] | |
nGirls = int(raw_input()) | |
aGirls = [int(i) for i in raw_input().split(' ')] | |
aBoys = sorted(aBoys) | |
aGirls = sorted(aGirls) | |
b = 0 | |
g = 0 |
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(raw_input()) | |
a = [int(i) for i in raw_input().split(' ')] | |
def flip(a, i, j): | |
for index in range(i, j + 1): | |
a[index] = 1 - a[index] | |
maxCount = -1 | |
for i in range(n): |
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(raw_input()) | |
a = [int(i) for i in raw_input().split(' ')] | |
maxElement = max(a) | |
count = {} | |
for ai in a: | |
count[ai] = count[ai] + 1 if ai in count else 1 | |
def getCount(ai): | |
return count[ai] if ai in count else 0 |
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
import math | |
[n, m] = [int(i) for i in raw_input().split(' ')] | |
f = [int(i) for i in raw_input().split(' ')] | |
f = sorted(f); | |
minDist = min([(f[i + n - 1] - f[i]) for i in range(m - n + 1)]) if m > n else f[n - 1] - f[0] | |
print minDist |
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
async function hello() { | |
var a = await Promise.resolve('Hello '); | |
return a; | |
} | |
(async function helloWorld() { | |
var hello = await hello(); | |
console.log(hello + 'World!'); | |
})(); |