2010-08-01から1ヶ月間の記事一覧

SRM479 Div2 Medium(500) TheCoffeeTimeDivTwo

TheCoffeeTimeDivTwo茶とコーヒーを同時にフラスコに入れることはできない。それぞれ遠い方から順に7人ずつ配っていけば良い。 #include <vector> #include <algorithm> using namespace std; class TheCoffeeTimeDivTwo { public: int find( int n, vector <int> tea ); }; int The</int></algorithm></vector>…

SRM479 Div2 Easy(250) TheAirTripDivTwo

TheAirTripDivTwo #include <vector> using namespace std; class TheAirTripDivTwo { public: int find( vector <int> flights, int fuel ); }; int TheAirTripDivTwo::find( vector <int> flights, int fuel ) { int n = (int)flights.size(); for ( int i=0; i</int></int></vector>

SRM479 Div1 Medium(500) TheAirTripDivOne

TheAirTripDivOne最小の待ち時間をなるべく長くすることでフライトの遅れに対して安全になる、ということだろうか? 二分探索。safetyをある値として、timeまでに街nに辿り着けるかを調べる。 #include <string> #include <vector> #include <numeric> #include <algorithm> #include <sstream> using name</sstream></algorithm></numeric></vector></string>…

SRM479 Div2 Hard(1000) TheBoardingDivTwo

TheBoardingDivTwo全通り試すだけ。後ろの乗客は、前の乗客が移動する時は移動できるけど、前の乗客が座る時は移動できない、ということに引っかかった。このために着席時間を75秒にするなら、制限時間も1秒増やす必要がある。 #include <vector> #include <algorithm> using na</algorithm></vector>…

SRM479 Div1 Easy(250) TheCoffeeTimeDivOne

TheCoffeeTimeDivOne茶とコーヒーを同時にフラスコに入れることはできない。それぞれ遠い方から順に7人ずつ配っていけば良い。コーヒーは、まず茶の乗客を除いて考え、茶の乗客を間に入れることで移動距離が増える乗客の数を足していく。 国際線でコーヒー…

SRM479

某祭典に行っていたため不参加。

SRM478 Div2 Hard(1000) RandomAppleEasy

RandomAppleEasy定義通りに計算しようとしたときに分母に出てくる数字(例1ならば2,3,5)は1000以下。分母の数字ごとに分子の数字を動的計画法で求める。i-1個目までの箱を考えたときに、分母jの項がn個で分子の合計がsならば、i個目の箱を加えることで、分…

SRM478 Div2 Easy(250) KiwiJuiceEasy

KiwiJuiceEasy #include <vector> using namespace std; class KiwiJuiceEasy { public: vector <int> thePouring( vector <int> capacities, vector <int> bottles, vector <int> fromId, vector <int> toId ); }; vector <int> KiwiJuiceEasy::thePouring( vector <int> capacities, vector <int> bottles, </int></int></int></int></int></int></int></int></vector>…

SRM478 Div1 Medium(500) KiwiJuice

KiwiJuiceボトルの集合Bから得られるジュースの量の組み合わせは、ジュースを寄せ集めるか、Bを2つに分けてそれぞれ再帰的にジュースを動かすかのどちらか。立っているビットの部分集合の列挙は↓のようにできるらしい。すげー。 #include <vector> using namespace s</vector>…

SRM478 Div1 Easy(250), Div2 Medium(500) CarrotJumping

CarrotJumping4(8x+7)+3 = 8(4x+3)+7 = 32x+31 であることから、4xジャンプと8xジャンプの順番に意味は無い。また、4xジャンプをk回したあとの位置は、 4(4(4(…(4x+3)…)+3)+3)+3 = 4kx+3(4k-1+4k-2+…+1) = 4kx+3(4k-1)/3 = 4k(x+1)-1、 8xジャンプをk回した…

SRM478

Easy (250) 106.51 4x+3が高々2回と気付くのに遅れたのが悔しい。とりあえず幅優先で解いてみるというのは重要かも。 Medium (500) 0 Hard (1000) 0 Challenge 0 結果 1516 → 1506ギリギリまだ黄色。

CodeForces Beta Round #25 B. Phone numbers

Phone numbers最後以外は2個ずつに区切れば良い。 n=input() x=raw_input() y="" for i in range(n): y+=x[i] if i%2==1 and i

CodeForces Beta Round #25 A. IQ test

IQ test n=input() x=map(int,raw_input().split()) e=[]; o=[] for i in range(n): if x[i]%2==0: e+=[i+1] else: o+=[i+1] if len(e)==1: print e[0] if len(o)==1: print o[0]