2014-08-09から1日間の記事一覧

UVa11926 Multitasking

UVa

解法 計算量が3*10^9くらいになるので嘘解法かもしれないが、いもす法で解いた。 #include <bits/stdc++.h> using namespace std; #define MAX (1000000) int main() { int N, M; while(cin >> N >> M && (N|M)) { int arr[MAX+1] = {}; for(int i=0; i<N; i++) { int s, t; cin >> s >> t; arr[s] ++;</n;></bits/stdc++.h>…

UVa11498 Division of Nlogonia

UVa

解法 #include <bits/stdc++.h> using namespace std; int main() { int K; while(cin >> K && K) { int N, M; cin >> N >> M; for(int i=0; i<K; i++) { int X, Y; cin >> X >> Y; if(N == X || M == Y) { cout << "divisa" << endl; } else { if(N < X && Y > M) cout << "NE" << endl; if(N > X && </k;></bits/stdc++.h>…

UVa11432 Busy Programmer

UVa

解法 dp[MICROの作業をした日数][GOOの作業をした日数][連続日数][現在取りかかっているプロジェクト 0 or 1] := パターン数 としてメモ化再帰。 #include <bits/stdc++.h> using namespace std; typedef long long ll; int D, G; ll memo[35][35][35][2]; ll solve(int mfi</bits/stdc++.h>…

SRM461 Div1Easy ColoringRectangle

SRM

解法 直径を大きい順にソートして(1)r,b,r,b,... or (2)b,r,b,r,...の順で貪欲でつめる。red or blue の要素で直径が H 以上のものが尽きたら -1 を出力。そうでなければ長方形の残りの幅を越えた時点で最適。(1)と(2)の小さい方が答え。 class ColoringRect…