记录到当前位置combo数为k的尾巴的最小值, 比如 1 3 2 6, 则 dp[combo]=tail 罗列为 dp[1]=1, dp[2]=2 (1,2的尾巴比1,3等小), dp[3]=6, combo最大为6. 然后再多加一位就看能不能更新前面combo数对应的tail, 让tail更小; 当然还看combo数能不能+1. 比如1 3 2 6再加个5, dp[3]就=5 (1,2,5的tail比1,2,6的tail小), 不加5加7就多一个dp[4]=7. 因为dp[combo]值相对于combo数是递增的, 所以可以二分查找实现nlogn.
这两个是买一送一的题目.. 1887的二分写的有点蛋疼.. 2533要求不能相等, 就加了个标记每次对二分的两个指针p0,p1, 和中点(p0+p1)/2看一下, 重复就continue, 不重复一样做, 省得麻烦.. 想了一下还可以前面严格<, 后面可以>=, 这样更新tail的时候就不会重复产生影响.
代码点下面:
POJ 1883
[cpp]#include <stdio.h>
int main() {
int a[5000];
int e[5000],N=0;
int nextline;
scanf("%d",&nextline);
while(nextline!=-1) {
N++;
int an=0;
while(nextline!=-1) {
an++;
a[an]=nextline;
scanf("%d",&nextline);
}
//DP it.
int en=0;
e[0]=0;
for(int i=an;i>=1;i–) {
int foo=0;
int p0=1,p1=en;
e[en+1]=0x7fffffff;
while(1) {
int p=(p1+p0)/2;
if(a[i]>=e[p] && a[i]<e[p+1]) {
p1=p0=p;
break;
}
if(a[i]<e[p])
p1=p-1;
if(a[i]>=e[p+1])
p0=p+1;
}
if(p0==en) {
en++;
e[en]=a[i];
}
else
e[p1+1]=a[i];
}
printf("Test #%d:\n maximum possible interceptions: %d\n\n",N,en);
scanf("%d",&nextline);
}
return 0;
}
[/cpp]
POJ 2533
[cpp]#include <stdio.h>
int main() {
int a[1005];
int e[1005];
int an;
scanf("%d",&an);
for(int i=1;i<=an;i++)
scanf("%d",a+i);
//DP it.
int en=0;
e[0]=0x80000000;
for(int i=1;i<=an;i++) {
int foo=0;
int p0=1,p1=en;
e[en+1]=0x7fffffff;
bool flag=true;
while(1) {
int p=(p1+p0)/2;
if(e[p0]==a[i] || e[p1]==a[i] || e[p]==a[i]) {
flag=false;
break;
}
if(a[i]>=e[p] && a[i]<e[p+1]) {
p1=p0=p;
break;
}
if(a[i]<e[p])
p1=p-1;
if(a[i]>=e[p+1])
p0=p+1;
}
if(!flag)
continue;
if(p0==en) {
en++;
e[en]=a[i];
}
else
e[p1+1]=a[i];
}
printf("%d\n",en>0?en:1);
return 0;
}
[/cpp]
References:
Legiano Casino Tischspiele http://www.ut2.ru/redirect/www.qazaqpen-club.kz/en/user/violinsalary22/
References:
KingMaker Casino Echtgeld App http://maps.google.com.qa/url?q=https://qrlinkgenerator.com/edisonmontague
References:
Casino Kingmaker https://blog.fc2.com/?jump=https://link.mym.ge/dedraweeks0743
References:
Legiano Casino Spielautomaten playground.ru
References:
Legiano Casino Kundenservice google.ga
References:
Legiano Casino Umsatzbedingungen http://ww.visit-x.net
References:
Kingmaker Casino Mirror Link http://schoener.de
References:
Legiano Casino Bonus maps.google.co.ls
References:
Hitnspin casino ohne anmeldung lginis.yoo7.com
References:
Monro Casino Schweiz https://wordpress.com
References:
Hitnspin casino auszahlung erfahrungen https://board-hu.darkorbit.com/proxy.php?link=https://forum.fpt.edu.vn/proxy.php?link=https://de.trustpilot.com/review/der-wikinger-shop.de
References:
Hitnspin casino login alt1.toolbarqueries.google.vg
References:
Hitnspin promo code http://clients1.google.sr/
References:
Monro Casino Deutschland https://old-site.bsau.ru
References:
Hitnspin aktionscode https://www.aichiyudemao.com/wp-content/themes/begin/inc/go.php?url=https://wargaming.net/id/openid/redirect/confirm/?next=https://de.trustpilot.com/review/der-wikinger-shop.de&game_realm=eu
References:
Hitnspin casino ähnliche casinos http://cse.google.com.nf/url?sa=i&url=http://cr.naver.com/redirect-notification?u=http://de.trustpilot.com/review/der-wikinger-shop.de
References:
Hit casino welqum.com
References:
Hitnspin casino auszahlungsdauer https://ca.do4a.pro/proxy.php?link=https://zenwriting.net/energyoyster12/der-hitnspin-willkommensbonus-alle-infos
References:
Hitnspin erfahrungen http://dec.2chan.net/bin/jump.php?https://500px.com/p/sellersjsijosephsen
References:
Hitnspin casino review termoportal.ru
References:
Hitnspin bonus ohne einzahlung http://www.prosvetlenie.org/forum/proxy.php?link=https://www.lanubedocente.21.edu.ar/profile/stanleyqtmboll51093/profile
References:
Hit n spin casino online login https://forum.reizastudios.com
References:
Hitnspin casino bonus http://kimberly-club.ru
References:
Hitnspin casino freispiele https://disput-pmr.ru/proxy.php?link=https://urlscan.io/result/019eb130-8ced-70ae-9076-74f45cae9467/
References:
Hitnspin casino live spiele http://shell.cnfol.com/adsence/get_ip.php?url=https://bmp.pw/alfonzoadler15
References:
Hit n spin casino 25 euro code garagebiz.ru
References:
Hitnspin casino app https://autoitscript.com/trac/autoit/search?q=https://sbfpageing.com/t8wcs
References:
Hit n spin freispiele http://nashi-progulki.ru
References:
Hit n spin promo code https://podnova.com/player/player_add_frame.php?url=https://k1t.kr/brittnyrunionhttps://podnova.com/player/player_add_frame.php?url=https://k1t.kr/brittnyrunion</a
References:
Hitnspin verifizierung http://www.aozhuanyun.com
References:
Lollybet Casino Bonusbedingungen http://lginis.yoo7.com/go/aHR0cHM6Ly9kaXZpdHViZS5jb20vQHBhdWxpbmVib2xsaWdlP3BhZ2U9YWJvdXQ
References:
Lollybet Casino No Deposit http://clients1.google.co.ao/
References:
Lollybet Alternative images.google.com.ly
References:
Lollybet Support http://www.google.co.ao
References:
Lollybet Casino Neukundenbonus bookwinx.ru
References:
Lollybet Casino Treueprogramm http://subscribe.esetnod32.ru
References:
Lollybet Casino Erfahrungen http://images.google.com.om/url?q=https://rentry.co/z3azvt6n
References:
Lollybet Casino Verifizierung https://m.so.com/index.php?q=www.zapztv.com/@dan08w07423428?page=about/
References:
Lollybet Casino Gutscheincode livesexcamgirls.chaturbate.com
References:
Hitnspin casino live http://clients1.google.fi/url?sa=t&url=https://school-of-safety-russia.ru/user/shareprint9/
References:
Hitnspin casino live http://cse.google.co.nz/url?q=https://atavi.com/share/xussnhzkpxvs
References:
Hitnspin casino spiele http://clients1.google.dj/url?q=https://atavi.com/share/xvvepwzsk3xr
References:
Hitnspin casino einzahlung clients1.google.bg
References:
Hitnspin casino auszahlung erfahrungen cse.google.off.ai
References:
Hitnspin casino trustpilot http://images.google.gr/url?sa=t&url=https://dreevoo.com/profile.php?pid=1938728
References:
Hit spin casino images.google.com.cy
References:
Hitnspin casino ähnliche casinos cse.google.cat
References:
Hit’n’spin casino 25 euro code maps.google.lt
References:
Payid pokies instant withdrawal https://code.letsbe.solutions/yieermelinda35
References:
Payid pokies online voomrecruit.com