Skip to content

Commit c6cf30f

Browse files
committed
GCJ2014 R2
1 parent 2dbe407 commit c6cf30f

File tree

6 files changed

+934
-0
lines changed

6 files changed

+934
-0
lines changed

GCJ/14/R2/A-large-practice.in

Lines changed: 201 additions & 0 deletions
Large diffs are not rendered by default.

GCJ/14/R2/A-small-practice.in

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
100
2+
8 66
3+
54 27 13 46 23 40 21 44
4+
10 161
5+
160 35 102 13 113 6 67 6 28 103
6+
10 280
7+
39 182 150 211 140 76 242 170 144 153
8+
5 678
9+
486 540 481 515 510
10+
6 144
11+
77 74 70 5 139 67
12+
10 407
13+
148 345 227 353 248 369 344 319 75 78
14+
3 277
15+
127 164 237
16+
6 606
17+
387 387 482 387 482 53
18+
8 273
19+
7 266 151 103 170 235 38 122
20+
6 220
21+
215 69 5 95 125 151
22+
7 417
23+
345 337 162 213 213 162 162
24+
6 388
25+
242 274 82 274 242 82
26+
10 438
27+
42 299 253 295 383 126 252 344 275 368
28+
6 125
29+
13 20 76 52 116 23
30+
10 700
31+
1 1 1 1 1 1 1 1 1 1
32+
10 278
33+
180 90 194 179 227 218 119 138 245 113
34+
8 357
35+
236 332 28 81 352 152 318 138
36+
7 424
37+
198 299 200 200 198 200 200
38+
10 13
39+
1 9 7 4 5 9 8 13 9 13
40+
1 497
41+
323
42+
4 425
43+
393 249 206 288
44+
9 553
45+
275 448 537 520 476 402 461 293 527
46+
4 512
47+
234 347 197 392
48+
6 236
49+
104 7 38 199 133 230
50+
8 592
51+
258 463 463 258 463 174 146 492
52+
7 330
53+
198 188 185 172 306 280 207
54+
10 432
55+
116 121 41 44 286 159 313 213 339 202
56+
10 680
57+
521 418 270 222 531 177 427 291 506 55
58+
7 33
59+
25 11 28 26 12 24 24
60+
5 383
61+
177 283 160 285 218
62+
10 161
63+
152 64 107 112 43 134 17 16 30 6
64+
4 198
65+
64 52 120 49
66+
8 321
67+
289 129 10 302 32 192 311 19
68+
6 670
69+
362 505 413 650 585 491
70+
5 687
71+
431 260 455 506 412
72+
6 600
73+
575 345 427 345 345 345
74+
10 223
75+
172 135 203 18 98 29 161 161 49 113
76+
9 211
77+
71 78 80 160 186 92 128 129 6
78+
10 560
79+
37 38 65 369 460 338 293 94 188 220
80+
10 172
81+
50 113 100 99 92 83 15 113 38 138
82+
8 26
83+
6 1 11 26 21 11 3 13
84+
10 495
85+
479 38 456 69 472 338 326 427 460 419
86+
8 457
87+
230 371 243 415 15 95 172 38
88+
6 564
89+
464 348 538 348 348 464
90+
10 482
91+
118 74 262 49 45 403 23 247 112 172
92+
10 677
93+
551 261 353 573 243 624 482 527 325 504
94+
6 645
95+
309 383 441 550 236 534
96+
4 195
97+
172 115 3 80
98+
10 90
99+
40 88 10 24 1 86 35 2 46 57
100+
9 462
101+
405 362 442 302 313 279 405 389 249
102+
5 241
103+
137 59 218 76 206
104+
7 503
105+
321 248 240 252 172 168 328
106+
5 660
107+
452 641 641 452 641
108+
10 24
109+
15 12 2 11 14 15 22 13 11 20
110+
10 1
111+
1 1 1 1 1 1 1 1 1 1
112+
10 22
113+
15 12 22 15 2 6 8 7 17 6
114+
10 489
115+
476 108 177 230 149 398 240 332 468 158
116+
1 98
117+
75
118+
6 571
119+
428 143 492 79 199 372
120+
10 443
121+
66 228 99 276 411 365 431 399 368 3
122+
6 667
123+
241 298 530 277 416 371
124+
5 287
125+
30 81 261 86 24
126+
10 377
127+
179 364 145 261 338 345 204 334 193 160
128+
10 420
129+
119 57 275 112 321 286 201 370 56 207
130+
6 670
131+
388 28 517 153 282 642
132+
8 626
133+
451 615 11 113 9 513 617 175
134+
10 441
135+
125 146 202 217 215 240 339 10 75 191
136+
10 317
137+
254 287 285 54 201 211 76 62 131 184
138+
7 236
139+
151 114 204 140 150 151 185
140+
3 328
141+
33 202 207
142+
8 441
143+
250 222 250 357 357 357 278 278
144+
10 45
145+
17 17 7 10 10 33 23 9 22 32
146+
10 577
147+
294 514 51 350 315 383 491 375 18 529
148+
2 325
149+
126 320
150+
7 344
151+
294 242 287 235 326 259 237
152+
5 342
153+
229 299 274 230 309
154+
10 296
155+
82 31 30 53 17 6 214 79 276 117
156+
5 167
157+
152 37 116 85 48
158+
7 461
159+
367 322 331 204 207 393 302
160+
6 108
161+
91 17 8 7 100 101
162+
6 545
163+
527 492 342 456 466 198
164+
10 116
165+
102 3 34 68 19 82 15 98 90 64
166+
10 637
167+
31 151 399 40 351 406 220 373 488 592
168+
6 452
169+
421 58 394 149 31 303
170+
7 491
171+
397 241 216 269 454 210 165
172+
10 92
173+
63 20 82 11 61 43 48 25 23 63
174+
10 273
175+
137 204 219 254 253 109 155 119 217 130
176+
10 18
177+
16 3 12 9 17 5 14 10 2 7
178+
10 459
179+
283 55 154 370 199 164 426 162 387 284
180+
10 569
181+
43 228 204 28 199 387 502 330 443 430
182+
10 280
183+
69 237 110 203 263 19 64 5 204 166
184+
2 428
185+
253 365
186+
9 236
187+
138 218 100 162 229 225 115 232 86
188+
10 83
189+
47 24 39 22 4 33 23 14 20 36
190+
8 277
191+
142 224 50 85 247 103 226 80
192+
9 366
193+
350 291 322 286 217 280 131 336 223
194+
10 237
195+
127 221 190 49 225 73 214 10 129 184
196+
6 56
197+
14 26 42 16 30 40
198+
8 664
199+
230 230 245 270 274 274 274 557
200+
8 225
201+
186 207 43 24 81 207 36 34

GCJ/14/R2/A.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include <algorithm>
2+
#include <iostream>
3+
#include <sstream>
4+
#include <string>
5+
#include <vector>
6+
#include <queue>
7+
#include <set>
8+
#include <map>
9+
#include <cstdio>
10+
#include <cstdlib>
11+
#include <cctype>
12+
#include <cmath>
13+
#include <string>
14+
#include <cstring>
15+
using namespace std;
16+
17+
#define REP(i,n) for(int i=0;i<(n);++i)
18+
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
19+
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
20+
#define FOREACH(it,c) for(typeof((c).begin())it=(c).begin();it!=(c).end();++it)
21+
#define CLR(x) memset((x),0,sizeof((x)))
22+
#define MP make_pair
23+
#define MPI make_pair<int, int>
24+
#define PB push_back
25+
typedef long long LL;
26+
typedef vector<int> VI;
27+
typedef vector<string> VS;
28+
typedef pair<int, int> PI;
29+
30+
#pragma warning(disable: 4996)
31+
32+
void run() {
33+
int X, N;
34+
scanf("%d %d", &N, &X);
35+
vector<int> mm(N);
36+
REP(i,N) scanf("%d", &mm[i]);
37+
38+
int res = 0;
39+
40+
sort(mm.begin(), mm.end());
41+
while (!mm.empty()) {
42+
if (mm.size() == 1) {
43+
++res;
44+
break;
45+
}
46+
47+
++res;
48+
int rt = mm.back();
49+
mm.pop_back();
50+
int v = X - rt;
51+
if (mm.front() > v) continue;
52+
53+
int lp = 0;
54+
int rp = mm.size() - 1;
55+
while (lp <= rp) {
56+
int mp = (lp + rp) / 2;
57+
if (mm[mp] > v) rp = mp - 1;
58+
else lp = mp + 1;
59+
}
60+
61+
if (rp != -1) {
62+
mm.erase(mm.begin() + rp, mm.begin() + rp + 1);
63+
}
64+
}
65+
66+
printf("%d\n", res);
67+
}
68+
69+
int main() {
70+
int nk;
71+
scanf("%d", &nk);
72+
FOR(c,1,nk) {
73+
printf("Case #%d: ", c);
74+
run();
75+
}
76+
return 0;
77+
}

0 commit comments

Comments
 (0)