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

为什么测试结果都对,还是WA呢???(带代码)#include<iostream>

Posted by wangchenx at 2010-11-13 16:04:30 on Problem 1065
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int i=0;
    while(i<n){
        int m,j=0;
        cin>>m;
        int l[5001],w[5001];
        while(j<m){
            cin>>l[j]>>w[j];
            j++;
        }
        for(int p=0;p<m;p++){
            for(int q=0;q<m;q++){
                if(l[q]<l[q+1]){
                    int k=l[q];
                    l[q]=l[q+1];
                    l[q+1]=k;
                    int h=w[q];
                    w[q]=w[q+1];
                    w[q+1]=h;
                }
                else if(l[q]==l[q+1]){
                    if(w[q]<w[q+1]){
                    int h=w[q];
                    w[q]=w[q+1];
                    w[q+1]=h;
                    }
                }
            }
        }
        int k=1;int h=0;
        for(int p=0;p<m;p++){
            if(w[h]<w[p])
                h=p;
        }
        for(int q=0;q<h;q++){
            if(w[q]<w[q+1])
                k++;
        }
        cout<<k<<endl;
        i++;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator