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 |
TLM一次,WA一次,附辣鸡代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator