This file contains hidden or 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
#include <cstdio> | |
#include <cmath> | |
#include <cstring> | |
#include <ctime> | |
#include <iostream> | |
#include <algorithm> | |
#include <set> | |
#include <vector> | |
#include <map> | |
#include <tuple> |
This file contains hidden or 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
class PairGame: | |
def maxSum(self, a, b, c, d): | |
partA = self.parts(a, b) | |
partC = self.parts(c, d) | |
group = sorted(list(partA.items()), reverse=True) | |
for g in group: | |
if partC.has_key(g[0]): | |
if partC[g[0]] == g[1]: | |
return g[0] | |
return -1 |
This file contains hidden or 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
# board[n][n] があるとする | |
table = [[0 for _ in xrange(N)] for _ in xrange(N)] | |
for c in xrange(N): | |
for r in xrange(N): | |
total = 0 | |
if c != 0: | |
total += table[c - 1][r] | |
if r != 0: | |
total += table[c][r - 1] |
This file contains hidden or 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 -*- | |
import math, string, itertools, fractions, heapq, collections, re, array, bisect | |
# .が1つもないのはk = 0と扱うと良い | |
class UniformBoard: | |
def getBoard(self, board, K): | |
N = len(board) | |
dots, apples, pears = self.count(board) | |
# print dots, apples, pears | |
if dots == 0: |
This file contains hidden or 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
#include <cstdio> | |
#include <cmath> | |
#include <cstring> | |
#include <ctime> | |
#include <iostream> | |
#include <algorithm> | |
#include <set> | |
#include <vector> | |
#include <sstream> | |
#include <typeinfo> |
This file contains hidden or 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
class BuildingHeights: | |
""" 4000 ** 2 -> T L E""" | |
def minimum(self, heights): | |
N = len(heights) | |
heights = list(heights) | |
heights.sort() | |
sums = [0 for _ in xrange(N+1)] | |
for i in xrange(N): | |
sums[i+1] = sums[i] + heights[i] |
This file contains hidden or 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
#include <iostream> | |
#include <map> | |
#include <string> | |
#include <vector> | |
#include <cstdio> | |
#include <math.h> | |
#include <algorithm> | |
#include <queue> | |
#include <tuple> | |
#include <stack> |
This file contains hidden or 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,string,itertools,fractions,heapq,collections,re,array,bisect, copy | |
class HappyLetterDiv1: | |
def getHappyLetters(self, letters): | |
letters = list(letters) | |
letters.sort() | |
cnt = collections.Counter() | |
for letter in letters: | |
cnt[letter] += 1 |
This file contains hidden or 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
#include <iostream> | |
#include <map> | |
#include <string> | |
#include <vector> | |
#include <cstdio> | |
#define FOR(i,a,b) for(int i=(a);i<(b);++i) | |
#define REP(i,n) FOR(i,0,n) | |
using namespace std; |
This file contains hidden or 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
int gcd(int a, int b){ | |
while(b){ | |
int bb = b; | |
b = a % b; | |
a = bb; | |
} | |
return a; | |
} |