intさわだんのBlack History

刹那的レジェンドになりたい。

2014-10-03から1日間の記事一覧

POJ(PKU) 3104 Drying

もう解きたくない・ 黒歴史ソース #include <cstdio> #include <algorithm> using namespace std; const int INF = 1000000002; int n,k,d[100003]; bool ch( long long int x){ long long int u = 0; for(int i = 0;i < n;i++){ if(d[i] > x){ u += (d[i] - x + k -2)/(k-1); }</algorithm></cstdio>…

蟻本の二分探索のところで、lower_bound,upper_bundあまり使わないの、なんとなくわかった気がする。

POJ(PKU) 3723 Monthly Expense

二分探索で最小値を求める。 #include <cstdio> using namespace std; const int INF = 100002; int n,m,d[1000002]; bool ch(int x){ int u = 1; int sum = 0; for(int i = 0;i < n;i++){ if(d[i] > x)return false; if(d[i] + sum > x){ u++; sum = d[i]; }else{ s</cstdio>…

POJ(PKU) 3258 River Hopscotch

顕著な二分探索。説明不要な気がする。 #include <cstdio> #include <algorithm> using namespace std; const int INF = 1000000001; int l,n,m,d[50001]={0}; bool ch(int x){ int u = 0; int pre = 0; for(int i = 1;i <= n+1;i++){ if(d[pre] + x > d[i]){ u++; }else{ pre =</algorithm></cstdio>…

POJ(PKU) 2456 Aggressive cows

蟻本にある。 二分探索使わなくても解けるのだろうか。 #include <cstdio> #include <algorithm> using namespace std; const int INF = 1000000001; int n,c,p[100001]; bool ch(int x){ int nau = 0,sum = 1,pre = p[nau]; while(nau < n && sum < c){ if(pre + x <= p[nau]){</algorithm></cstdio>…

第6回日本情報オリンピック 本選 「最軽量のモビール」

ひとつ前の「最悪の記者」のほうが少し難易度が高いきがする。部分点解法全く思いつきませんでしたすいません。 満点解法 深さ優先探索(DFS)をする. まず一番上にあるモビール(?)をもとめる。 そのモビールを関数dfsに投げる 関数dfsはそのモビールに必要…

POJ復活してた