dp 點擊打開鏈接
單調遞增子序列 [二分法] 轉移方程和邊界條件點擊打開鏈接
7
1 9 10 5 11 2 13
2
2 -1
樣例輸出
5
1
心急的C小加(題外)點擊打開鏈接
3
5
4 9 5 2 2 1 3 5 1 4
3
2 2 1 1 2 2
3
1 3 2 2 3 1
樣例輸出
2
1
3
矩陣嵌套
1
10
1 2
2 4
5 8
6 10
7 9
3 1
5 8
12 10
9 7
2 2
樣例輸出
5
郵局 [中位數]點擊打開鏈接
1
10 5
1 2 3 6 7 9 11 22 44 50
樣例輸出
9
子串和 [枚舉]
1
5
1 2 -1 3 -2
樣例輸出
5
股票 [逆差]
4
947 267 359 771
7
669 735 322 794 397 565 181
樣例輸出
504
472
探尋寶藏 點擊打開鏈接
傳紙條(一) 雙線程dp 點擊打開鏈接
1
3 3
0 3 9
2 8 5
5 7 0樣例輸出
34
子串和再續 使m個子串和最大點擊打開鏈接
1
3 6
-1 4 -2 3 -2 4
樣例輸出
11
石子合併 區間dp點擊打開鏈接
圓形操場
螞蟻的難題(四)點擊打開鏈接
#include
#include
int p[10001];
char str[10001];
int main()
{
int m,max;
scanf("%d",&m);
while(m--)
{
int i,j,len;
scanf("%s",str);
len=strlen(str);
p[0]=1;
for(i=1,max=1;i=0;j--)
if(str[i]>str[j]&&p[i]
// lower_bound/upper_bound example
#include // std::cout
#include // std::lower_bound, std::upper_bound, std::sort
#include // std::vector
int main () {
int myints[] = {10,20,30,30,20,10,10,20};
std::vector<int> v(myints,myints+8); // 10 20 30 30 20 10 10 20
std::sort (v.begin(), v.end()); // 10 10 10 20 20 20 30 30
std::vector<int>::iterator low,up;
low=std::lower_bound (v.begin(), v.end(), 20); // ^
up= std::upper_bound (v.begin(), v.end(), 20); // ^
std::cout << "lower_bound at position " << (low- v.begin()) << '\n';
std::cout << "upper_bound at position " << (up - v.begin()) << '\n';
return 0;
}
template
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val)
{
ForwardIterator it;
iterator_traits::difference_type count, step;
count = distance(first,last);
while (count>0)
{
it = first; step=count/2; advance (it,step);
if (*it#include
#include
using namespace std;
const int MAX=100100;
int num[MAX],top;
int main()
{
int n,i,*p;
while(scanf("%d",&n)!=EOF)
{
scanf("%d",&num[0]);
top=1;
for( i=1;i#include
int a[100005];
int dp[100005];
int binarysearth(int x,int len)
{
int left=1,right,mid;
right=len;
mid=(left+right)/2;
while(left<=right)
{
if(x>dp[mid])
{
left=mid+1;
}
else
if(xlen)
len=j;
}
printf("%d\n",len);
}
return 0;
}
// lower_bound/upper_bound example
#include // std::cout
#include // std::lower_bound, std::upper_bound, std::sort
#include // std::vector
int main () {
int myints[] = {10,20,30,30,20,10,10,20};
std::vector<int> v(myints,myints+8); // 10 20 30 30 20 10 10 20
std::sort (v.begin(), v.end()); // 10 10 10 20 20 20 30 30
std::vector<int>::iterator low,up;
low=std::lower_bound (v.begin(), v.end(), 20); // ^
up= std::upper_bound (v.begin(), v.end(), 20); // ^
std::cout << "lower_bound at position " << (low- v.begin()) << '\n';
std::cout << "upper_bound at position " << (up - v.begin()) << '\n';
return 0;
}
template
ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val)
{
ForwardIterator it;
iterator_traits::difference_type count, step;
count = distance(first,last);
while (count>0)
{
it = first; step=count/2; advance (it,step);
if (*it#include
#include
using namespace std;
const int MAX=100100;
int num[MAX],top;
int main()
{
int n,i,*p;
while(scanf("%d",&n)!=EOF)
{
scanf("%d",&num[0]);
top=1;
for( i=1;i#include
int a[100005];
int dp[100005];
int binarysearth(int x,int len)
{
int left=1,right,mid;
right=len;
mid=(left+right)/2;
while(left<=right)
{
if(x>dp[mid])
{
left=mid+1;
}
else
if(xlen)
len=j;
}
printf("%d\n",len);
}
return 0;
}
#include
#include
int p[10001];
char str[10001];
int main()
{
int m,max;
scanf("%d",&m);
while(m--)
{
int i,j,len;
scanf("%s",str);
len=strlen(str);
p[0]=1;
for(i=1,max=1;i=0;j--)
if(str[i]>str[j]&&p[i]
#include //#include using namespace std; int main() { //freopen("1.txt","r",stdin); int n ; cin>>n; while(n--) { string str; int count=1; cin>>str; int a[200],p[200]; a[0]=-999; for (int i=0;i=0;j--) { if((int)str[i]>a[j]) { a[j+1]=str[i]; p[j+1]=i; if(j+1==count) count++; break; } } } for(int i=1;i // std::cout #include // std::lower_bound, std::upper_bound, std::sort #include // std::vector int main () { int myints[] = {10,20,30,30,20,10,10,20}; std::vector v(myints,myints+8); // 10 20 30 30 20 10 10 20 std::sort (v.begin(), v.end()); // 10 10 10 20 20 20 30 30 std::vector::iterator low,up; low=std::lower_bound (v.begin(), v.end(), 20); // ^ up= std::upper_bound (v.begin(), v.end(), 20); // ^ std::cout << "lower_bound at position " << (low- v.begin()) << '\n'; std::cout << "upper_bound at position " << (up - v.begin()) << '\n'; return 0; } lower_bound at position 3 upper_bound at position 6 template ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val) { ForwardIterator it; iterator_traits::difference_type count, step; count = distance(first,last); while (count>0) { it = first; step=count/2; advance (it,step); if (*it #include using namespace std; const int MAX=100100; int num[MAX],top; int main() { int n,i,*p; while(scanf("%d",&n)!=EOF) { scanf("%d",&num[0]); top=1; for( i=1;i int a[100005]; int dp[100005]; int binarysearth(int x,int len) { int left=1,right,mid; right=len; mid=(left+right)/2; while(left<=right) { if(x>dp[mid]) { left=mid+1; } else if(xlen) len=j; } printf("%d\n",len); } return 0; } #include #include //#include using namespace std; int main() { //freopen("1.txt","r",stdin); int n ; cin>>n; while(n--) { string str; int count=1; cin>>str; int a[200],p[200]; a[0]=-999; for (int i=0;i=0;j--) { if((int)str[i]>a[j]) { a[j+1]=str[i]; p[j+1]=i; if(j+1==count) count++; break; } } } for(int i=1;i