Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 漂亮MM，那都是浮云那......

Posted by mixter at 2006-08-09 21:46:22 on Problem 2051
In Reply To:为什么wa?哪位牛人可以帮小妹看一下吗? Posted by:aime at 2006-08-09 20:37:56
```> #include<iostream>
> using namespace std;
> int num,k;
> struct command{
>     int q_num;
> 	int period;
> 	int nextime;
> }query[1001];
> void copy(int s,int j){
>     query[s].nextime=query[j].nextime;
> 	query[s].period=query[j].period;
> 	query[s].q_num=query[j].q_num;
> }
> int compare(int i,int j){
>     if(query[i].nextime<query[j].nextime)
> 		return -1;
> 	if(query[i].nextime>query[j].nextime)
> 		return 1;
> 	if(query[i].q_num<query[j].period)
> 		return -1;
> 	if(query[i].q_num>query[j].q_num)
> 		return 1;
> 	return 0;
> }
> 	int j;
>     copy(0,s);
> 	for(j=s*s;j<=num;j*=2){
> 	    if(j<num&&compare(j,j+1)>0)
> 			++j;
> 		if(compare(0,j)<=0)
> 			break;
> 		copy(s,j);
> 		s=j;
> 	}
> 	copy(s,0);
>
> }
> int HeapSort(){
> 	int left,right;
> 	for(left=num/2;left>=1;left--)
> 	for(right=1;right<=k;right++)
> 	{
> 		printf("%d\n",query[1].q_num);
> 		query[1].nextime+=query[1].period;
> 	}
> 		  return 0;
>
> }
> int main(){
> 	int i,j,q_num,period;
> 	char c[9];
> 	//freopen("test.txt","r",stdin);
> 	i=1;
> 	cin>>c;
> 	while(strcmp(c,"#")){
> 	    cin>>q_num>>period;
>         query[i].nextime=period;
> 		query[i].period=period;
> 		query[i].q_num=q_num;
> 		i++;
> 		cin>>c;
> 	}
> 	num=i-1;
> 	cin>>k;
> 	HeapSort();
> 	return 0;
> }
>
>
>
```

Followed by: