| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:如何做到0毫秒的.......In Reply To:如何做到0毫秒的....... Posted by:200730720207 at 2009-05-05 15:37:52 感觉跟背包有点相似,自己的数据都过了,就是交不上。。哪位大牛有牛逼的数据试试
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
struct data{
int count ;
int max ;
} f[10001];
int n,maxv;
int v[1001];
while(scanf("%d",&n)!=EOF){
maxv = 0;
for(int i=1;i<=n;i++){
scanf("%d",&v[i]);
if(v[i]>maxv)
maxv = v[i];
}
for(int i=1;i<=n;i++){
for(int j=v[i];j<=maxv;j++){
if(v[i]>f[j].max){
f[j].max = v[i];
f[j].count++;
}
if(v[i]<=f[j].max){
int num = f[j].count;
int rear = j;
while(rear>=0&&f[rear].count == num){
f[j].max = f[rear].max;
rear--;
}
}
}
}
printf("%d\n",f[maxv].count);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator