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 <stdio.h> #include <algorithm> using namespace std; int main() { while(1){ int r, n; scanf("%d%d", &r, &n); if(!(~r) && !(~n)) { break; } int ns[1010]; for(int i = 0; i < n; i++) scanf("%d", &ns[i]); sort(ns, ns+n); int offset = 0, cnt = 0; while(offset < n){ int zuo = offset; int pos = offset; for(; pos < n && ns[pos] <= ns[zuo]+r; pos++){ ; } cnt++; offset = pos; for(; offset < n && ns[offset] <= ns[pos-1]+r; offset++){ ; } } printf("%d\n", cnt); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator