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 |
是不是有问题啊?谁能帮我看一下,怎么回事啊?#include <iostream> #include <algorithm> using namespace std; int number[1000]; int main() { int tcase, score[2]; int n, a, b, minTag, pre, turn; cin>>tcase; int i, j; bool end; while(tcase--) { cin>>n>>a>>b; for(i = 0; i < n; i++) cin>>number[i]; score[0] = score[1] = 0; sort(number, number+n); for(i = n-1; (i >= 0) && (number[i] > b); i--) ; if((i < 0) || (number[i] < a)) { cout<<"0"<<endl; break; } pre = number[i]; minTag = i; turn = 1; score[0] += pre; end = false; while(!end) { end = true; for(i = n-1; (i > minTag) && (number[i]-pre) > b; i--) ; if((i <= minTag) || ((number[i]-pre) < a)) break; score[turn%2] += number[i]; pre = number[i]; minTag = i; end = false; turn++; } cout<<score[0]-score[1]<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator