锘??xml version="1.0" encoding="utf-8" standalone="yes"?>精品一久久香蕉国产线看播放 ,少妇熟女久久综合网色欲,日产久久强奸免费的看http://m.shnenglu.com/zqsand/category/12852.html鍟ユ槸瀛愭爣棰?/description>zh-cnWed, 20 Jan 2010 11:25:04 GMTWed, 20 Jan 2010 11:25:04 GMT60USACO 0912 鏈堣禌http://m.shnenglu.com/zqsand/archive/2009/12/13/103138.htmlrikisandrikisandSun, 13 Dec 2009 13:14:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/12/13/103138.htmlhttp://m.shnenglu.com/zqsand/comments/103138.htmlhttp://m.shnenglu.com/zqsand/archive/2009/12/13/103138.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/103138.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/103138.htmlsilver緇勶細

姣旇禌閭eぉ鎰熷啋錛岀涓棰樺氨寮勬檿浜嗭紝鐜板湪棰樿В鍑烘潵浜嗭紝琛ヤ笂鍚~

鏆傛椂鍙湁絎竴棰樼殑錛?/p>

Problem 6: Bobsledding [Brian Jacokes, 2009]

Bessie has entered a bobsled competition because she hopes her hefty
weight will give her an advantage over the L meter course (2 <= L
<= 1,000,000,000).

Bessie will push off the starting line at 1 meter per second, but
her speed can change while she rides along the course. Near the
middle of every meter Bessie travels, she can change her speed
either by using gravity to accelerate by one meter per second or
by braking to stay at the same speed or decrease her speed by one
meter per second.

Naturally, Bessie must negotiate N (1 <= N <= 100,000) turns on the
way down the hill. Turn i is located T_i meters from the course
start (1 <= T_i <= L-1), and she must be enter the corner meter at
a speed of at most S_i meters per second (1 <= S_i <= 1,000,000,000).
Bessie can cross the finish line at any speed she likes.

Help Bessie learn the fastest speed she can attain without exceeding
the speed limits on the turns.

Consider this course with the meter markers as integers and the
turn speed limits in brackets (e.g., '[3]'):

|   1   2   3   4   5   6   7[3]
|---+---+---+---+---+---+---+
|                            \
Start                         + 8    
                               \
                                + 9    
                                 \
                                  + 10       +++ 14 (finish)
                                   \         /
                              11[1] +---+---+
                                        12  13[8]

Below is a chart of Bessie's speeds at the beginning of each meter length
of the course:

Max:                              3               1       8
Mtrs: 0   1   2   3   4   5   6   7   8   9  10  11  12  13  14 
Spd:  1   2   3   4   5   5   4   3   4   3   2   1   2   3   4

Her maximum speed was 5 near the beginning of meter 4.

PROBLEM NAME: bobsled

INPUT FORMAT:

* Line 1: Two space-separated integers: L and N

* Lines 2..N+1: Line i+1 describes turn i with two space-separated
        integers: T_i and S_i

SAMPLE INPUT (file bobsled.in):

14 3
7 3
11 1
13 8

OUTPUT FORMAT:

* Line 1: A single integer, representing the maximum speed which
        Bessie can attain between the start and the finish line,
        inclusive.

SAMPLE OUTPUT (file bobsled.out):

5

 

棰樼洰鐪嬭搗鏉ユ尯澶嶆潅錛屽叾瀹炰富瑕佹槸姹傚嚭鍚勪釜turn澶勭殑鏈澶ч熷害錛屽垎鏋愬緱鍒版瘡涓猼urn鐨勬渶澶ч熷害闇瑕佹弧瓚充笁涓潯浠訛紝 M_i = min (S_i , t_i – t_{i-1} + M_{i-1} , S_k + t_k – t_i [for all k > i ] )

鍥犳澶勭悊姣忎竴涓猼urn閮借鏌ヨN涓猼urn N*N鐨勫鏉傚害鏄劇劧瀵逛簬澶ф暟鎹TLE鐨?/font>

閫嗗悜鎬濊冿紝濡傛灉鎴戜滑鍙嶈繃鏉ヨ冭檻錛屽浜庢瘡涓涓箣鍚庣殑turn鏉ヨ 濡傦細i  濡傛灉浠栨渶澶ч熷害涓?m_i

閭d箞 鍦╰urn i-1澶勶紝浠栦笉鑳借秴榪囩殑鏈澶ч熷害 m_{i-1} = min(S_i,m_i+t_i – t_{i-1});榪欐牱鎴愬姛鐨勬妸鍚庨潰涓や釜闄愬埗杞崲涓洪嗘帹鐨勭粨鏋滆屼笉鏄悜鍚庢煡璇?/font>

鍓╀笅鐨勯棶棰樹究鏄鏋滅煡閬撲袱涓猼urn涔嬮棿璺濈錛屼互鍙妕urn鐨勯熷害鏈澶у鹼紝濡備綍姹傚嚭涔嬮棿鐨勬渶澶у鹼紝鐢誨浘鏄劇劧鍙互寰楀埌涓縐嶇畻寮?maxspeed = min(s1,s2) + (dist2-dist1+abs(s1-s2))/2;

鎴栬?maxspeed = max(s1,s2) + (dist2 – dist1 – abs(s1-s2))/2;

娉ㄦ剰鍦ㄥ紑澶村拰緇撳熬鍔犲叆铏氭嫙鐨則urn灝卞彲浠ヤ簡

 

Code Snippet
#define REP(i,n)  for(  int (i) = 0 ; i < (n) ; ++i)
using namespace std;
int L,N;
struct node{
    int dist;
    int speed;
};
vector<node> vec;
bool comp(const node& n1,const node& n2){
    return n1.dist<n2.dist;
}
vector<int> up,down;
#define inf 98765433
void solve()
{
    //freopen("e:\\usaco\\bobsled.11.in","r",stdin);
    freopen("bobsled.in","r",stdin);
    freopen("bobsled.out","w",stdout);
    cin>>L>>N;
    vec.resize(N+2); up.resize(N+2,0); down.resize(N+2,0);
    vec[0].dist =0;vec[0].speed =1;
    vec[N+1].dist =L;vec[N+1].speed=inf;
    REP(i,N) scanf("%d %d",&vec[i+1].dist,&vec[i+1].speed);
    sort(vec.begin(),vec.end(),comp);
    down[N+1] = inf;
    for(int i=N;i>0;i--)
        down[i] = min(vec[i].speed,vec[i+1].dist-vec[i].dist+down[i+1]);
    int maxspeed = 1;up[0]=1;
    for(int i=1;i<N+2;i++){
        up[i] = min(down[i],up[i-1]+vec[i].dist - vec[i-1].dist);
        maxspeed = max(maxspeed,min(up[i],up[i-1])+(vec[i].dist-vec[i-1].dist+abs(up[i]-up[i-1]))/2);
    }
    cout<<maxspeed<<endl;
}


int main()
{
    solve();
    return 0;
}

 

 



rikisand 2009-12-13 21:14 鍙戣〃璇勮
]]>
[USACO 09NOV] silver xoinc [dp]http://m.shnenglu.com/zqsand/archive/2009/11/12/100754.htmlrikisandrikisandWed, 11 Nov 2009 16:20:00 GMThttp://m.shnenglu.com/zqsand/archive/2009/11/12/100754.htmlhttp://m.shnenglu.com/zqsand/comments/100754.htmlhttp://m.shnenglu.com/zqsand/archive/2009/11/12/100754.html#Feedback0http://m.shnenglu.com/zqsand/comments/commentRss/100754.htmlhttp://m.shnenglu.com/zqsand/services/trackbacks/100754.html鍛ㄥ叚絎竴嬈″仛usaco鐜╋紝bronze鐨勮交鏉懼垏鎺夛紝鐒跺悗鐢寵promote錛屼笅鍗堟壒鍑嗭紝璇濊rob 鏁堢巼濂介珮鍟妦 浜庢槸緇х畫鍋歴ilver 灝遍亣鍒拌繖涓- -錛佺籂緇撲簡鍗婂ぉ鏀懼純····鐭ラ亾鏄痙p 涔熻冭檻浜嗘柟娉曞氨鏄?鐞嗕笉娓呮錛涗笉鐭ラ亾鏄笉鏄竴澶╂病鍚冮キ鐨勭紭鏁?#183;····

浠婂ぉ棰樿В鍑烘潵浜唦 鍏堢湅浜嗗ぇ姒傛濊礬 鐒跺悗鑷繁鍐欏嚭鏉ヤ簡~

棰樼洰錛?/font>

Farmer John's cows like to play coin games so FJ has invented with
a new two-player coin game called Xoinc for them.

Initially a stack of N (5 <= N <= 2,000) coins sits on the ground;
coin i from the top has integer value C_i (1 <= C_i <= 100,000).

The first player starts the game by taking the top one or two coins
(C_1 and maybe C_2) from the stack. If the first player takes just
the top coin, the second player may take the following one or two
coins in the next turn. If the first player takes two coins then
the second player may take the top one, two, three or four coins
from the stack. In each turn, the current player must take at least
one coin and at most two times the amount of coins last taken by
the opposing player. The game is over when there are no more coins
to take.

Afterwards, they can use the value of the coins they have taken
from the stack to buy treats from FJ, so naturally, their purpose
in the game is to maximize the total value of the coins they take.
Assuming the second player plays optimally to maximize his own
winnings, what is the highest total value that the first player can
have when the game is over?

MEMORY LIMIT: 20 MB

PROBLEM NAME: xoinc

INPUT FORMAT:

* Line 1: A single integer: N

* Lines 2..N+1: Line i+1 contains a single integer: C_i

SAMPLE INPUT (file xoinc.in):

5
1
3
1
7
2
綆鍗曟潵璇村氨鏄袱涓漢杞祦鍙朿oins錛屾瘡涓漢姣忔鍙栧緱涓暟涓?- 2*n;n涓轟笂涓杞鏂瑰彇寰楁暟鐩紝
姹備袱涓漢閮芥槸鐢ㄦ渶浣崇瓥鐣ワ紝鍏堝彇寰楅偅涓浼欐渶澶氳兘鎷垮埌澶氬皯紜竵銆傝矊浼煎彲浠ョ畻鏄畝鍗曞崥寮堣鐨勬濇兂
鎬濊礬錛?/font>
        coins[1···N] 浠庝笅鍒頒笂 sum[1···N] 鍓╀笅 i涓殑鍜?/font>
        鎵懼埌鏃犲悗鏁堟х殑瀛愰棶棰樸傝冭檻鍦ㄨ繕鍓╀笅p涓挶甯佹椂鍊欑殑鎯呭喌錛屾鏃跺彲浠ユ嬁k涓挶
鐢變簬鏉′歡錛宬鐨勫ぇ灝忓彈涓婁竴杞嬁鐨勪釜鏁癷鐨勯檺鍒?錛屾墍浠ユ垜浠鍔犱笂涓涓彉閲廼銆傚緱鍒?/font>
dp[p][i]榪欎釜瀛愰棶棰樸傞偅涔堝鏄撳緱鍒?/font>
dp[p][i]=max(1=<k<=i*2){SuM(p to p-k+1)+SuM(p-k to 1)-dp[p-k][k]}
            =max(1=<k<=i*2){sum[p]-dp[p-k][k]}
鎸夌収榪欎釜鍙互寰楀埌涓涓狾錛圢^3錛夌殑綆楁硶

oidsolve(){
  
for(inti=1;i<=N;i++)//鍓╀笅i涓?br>        for(intj=1;j<=N;j++)//涓婁竴浜烘嬁浜唈 涓?br>            for(intk=1;k<=j*2&&i-k>=0;k++){
                dp[i][j]=max(dp[i][j],sum[
1]-sum[i+1]-dp[i-k][k]);
            }
    ret=dp[N][
1];
}

 涓夐噸閫掑綊 錛屾渶澶氬彲浠ヨ繃500鐨勬暟鎹噺  瑙傚療鍙互寰楀嚭 dp[p][j] 鍜?dp[p][j+1] 鐨勮綆楁湁寰堝鐨勯噸鍙?br>鍥犱負 涓婃鎷夸簡j+1 鍒欏彲浠ユ瘮 dp[p][j] 澶氭嬁 2 涓?nbsp;

鐒跺悗錛岀敱浜庤冭檻j鐨勮寖鍥?搴旇涓?N-i+1

榪欐牱寰楀埌浜嗘渶緇堜唬鐮侊細

    scanf("%d",&N); 
    for(int i=1;i<=N;i++)    scanf("%d",coins+i);//{fin>>coins[i]; }
    sum[0]=0;
    for(int i=1;i<=N;i++)     sum[i]=sum[i-1]+coins[N-i+1];  
    for(int i=1;i<=N;i++)        //鍓?涓?i 涓?
    for(int j=1;j<= N-i +1;j++){ // 涓?嬈?鎷?浜?j 涓?
    if(dp[i][j]<dp[i][j-1])dp[i][j]=dp[i][j-1];
    if(2*j-1<=i&&dp[i][j]<sum[i]-dp[i-2*j+1][2*j-1]) dp[i][j]=sum[i]-dp[i-2*j+1][2*j-1];
    if(2*j<=i&&dp[i][j]<sum[i]-dp[i-2*j][2*j]) dp[i][j]= sum[i]-dp[i-2*j][2*j];
    } 
    printf("%d\n",dp[N][1]);

寰堟櫄浜?錛屽厛鍐欒繖涔堝 錛屾湁絀烘妸bronze鐨勫啓浜?/strong>



rikisand 2009-11-12 00:20 鍙戣〃璇勮
]]>
久久久久无码中| 亚洲va久久久噜噜噜久久狠狠| 欧美牲交A欧牲交aⅴ久久| 国产亚洲精品美女久久久| 99久久国产综合精品五月天喷水| 91精品久久久久久无码| 久久久久亚洲国产| 狠狠色噜噜狠狠狠狠狠色综合久久| 大香网伊人久久综合网2020| 一日本道伊人久久综合影| 色综合久久中文综合网| 怡红院日本一道日本久久 | 综合久久一区二区三区 | 久久午夜无码鲁丝片秋霞| 国产精品美女久久久| 久久久久人妻一区二区三区| 狠狠久久亚洲欧美专区| 久久综合香蕉国产蜜臀AV| 草草久久久无码国产专区| 久久人人爽人人爽人人片av高请| 久久久久亚洲AV无码去区首| 丰满少妇人妻久久久久久| 一本久久免费视频| 久久影视国产亚洲| 精品久久人人做人人爽综合| 久久er国产精品免费观看2| 亚洲国产精品成人久久| 精品熟女少妇AV免费久久| 香蕉久久久久久狠狠色| 国産精品久久久久久久| 99久久99久久精品国产片果冻| 久久久久久夜精品精品免费啦| 国产欧美久久久精品影院| 久久久久久国产精品美女 | 无码人妻精品一区二区三区久久久| 日日狠狠久久偷偷色综合免费| 久久亚洲国产午夜精品理论片| 国产99久久精品一区二区| 99久久久精品| 狠狠精品久久久无码中文字幕| 久久久久久久综合日本亚洲|