第二章 网站建设,网站集群建设必要性,微信提示WordPress登录,wordpress外观自定义https://vjudge.net/problem/POJ-3069 弄清楚一点#xff0c;第一个stone的位置#xff0c;考虑左右两边都要覆盖R#xff0c;所以一般情况下不会在左边第一个#xff08;除非前两个相距R#xff09;。 一开始二层循环外层写的i1#xff0c;这样对于数据诸如1 1 1第一个stone的位置考虑左右两边都要覆盖R所以一般情况下不会在左边第一个除非前两个相距R。 一开始二层循环外层写的i1这样对于数据诸如1 1 10而其实结果是1. 1 #includeiostream2 #includecstdio3 #includequeue4 #includecstring5 #includealgorithm6 #includecmath7 #includeset8 #define INF 0x3f3f3f3f9 typedef long long ll;
10 using namespace std;
11 int R, n, a[1010];
12 int main()
13 {
14 while(cin R n){
15 if(R -1n -1) break;
16 for(int i 0; i n; i){
17 cin a[i];
18 }
19 sort(a, an);
20 int flag0;
21 int st 0, ans0;//st表示第一个未被覆盖的点
22 for(int i 0; i n;){//一开始这里写的i0WA了
23 while(i na[i]-a[st]R){
24 i;
25 }
26 int t i-1;//此处放一个
27 ans;
28 while(i na[i]-a[t]R){
29 i;
30 }
31 st i;
32 }
33 cout ans endl;
34 }
35 return 0;
36 } 转载于:https://www.cnblogs.com/Surprisezang/p/9000523.html