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

TLM一次,WA一次,附辣鸡代码

Posted by cxlm at 2018-01-19 10:11:46 on Problem 3663
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,s,cow[30000],res=0;
    while(scanf("%d%d",&n,&s)!=EOF){
    for(int i=0;i<n;i++){
        cin>>cow[i];
    }
    sort(cow,cow+n);
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(cow[i]+cow[j]<s){
              res++;
              }else if(cow[i]+cow[j]==s){
              res++;
              }else{
              break;
              }
        }
    }
    cout<<res<<endl;
    res=0;
    }
    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