QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#647188#8354. T2songziyan0 744ms63244kbC++141.2kb2024-10-17 12:32:062024-10-17 12:32:07

Judging History

你现在查看的是最新测评结果

  • [2024-10-17 12:32:07]
  • 评测
  • 测评结果:0
  • 用时:744ms
  • 内存:63244kb
  • [2024-10-17 12:32:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
char buf[1<<22],*p1,*p2;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2)?0:*p1++)
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch))f=(ch=='-')?-1:1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
const int N=2e6+5;
int n,K,q,B,op[5005],x[5005],ans[5005],f[N],g[N],p[N],v[N],t[N],vis[N];
void add1(int i){for(int j=K;j>=t[i];j--)f[j]=max(f[j],f[j-t[i]]+v[i]);}
void add2(int i){for(int j=K/p[i];j>=v[i];j--)if(g[j-v[i]]+t[i]<=K)g[j]=min(g[j],g[j-v[i]]+t[i]);}
signed main(){
    n=read();q=read();K=read();B=q;
    for(int i=1;i<=n;i++)p[i]=read(),v[i]=read(),t[i]=p[i]*v[i];
    for(int i=1;i<=q;i++)op[i]=read(),x[i]=read(),vis[x[i]]=op[i]==1;
    memset(g,0x3f,sizeof(g));g[0]=0;
    for(int i=1;i<=n;i++)if(!vis[i]){if(p[i]<=B)add1(i);else add2(i);}
    for(int i=q;i>=1;i--)
        if(op[i]==1){if(p[x[i]]<=B)add1(x[i]);else add2(x[i]);}
        else{int &res=ans[i];for(int j=x[i]/B;j>=0;j--)if(x[i]>=g[j])res=max(res,f[x[i]-g[j]]+j);}
    for(int i=1;i<=q;i++)if(op[i]==2)printf("%lld\n",ans[i]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 30672kb

input:

3205 5000 5000
1 1
2 1
3 1
7 1
8 1
9 1
10 1
11 1
12 2
13 1
14 2
16 1
17 2
20 3
22 1
24 1
26 2
27 1
30 1
32 2
33 1
34 1
41 1
44 2
49 2
51 1
54 2
58 2
61 2
65 2
66 1
68 2
70 1
71 2
72 2
74 8
75 3
76 5
77 1
78 7
79 5
80 5
81 1
82 2
84 1
86 6
87 6
88 3
89 9
90 5
91 1
92 2
93 3
95 7
96 2
97 2
98 8
99 8
1...

output:

85
73
35
44
46
95
35
87
47
54
96
74
57
70
86
54
72
63
91
42
71
74
84
49
54
69
92
47
40
79
32
67
77
7
57
61
79
21
47
54
50
39
78
59
33
46
82
79
51
84
70
91
39
23
78
25
92
41
72
57
61
29
50
63
60
73
30
89
28
45
68
63
38
65
6
46
38
79
67
58
91
77
88
63
43
41
49
52
94
73
66
25
86
88
34
89
61
92
85
84
70...

result:

wrong answer 1st lines differ - expected: '81', found: '85'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 38ms
memory: 63244kb

input:

1277351 1 2000000
2 2
5 1
7 3
8 4
10 1
12 1
15 2
16 1
18 1
22 1
25 1
28 3
29 1
32 1
35 1
36 1
38 2
40 1
41 2
42 1
43 2
44 2
45 1
48 1
49 1
50 2
54 2
55 2
56 1
58 2
59 2
60 2
62 1
66 1
68 3
69 1
70 3
72 2
76 1
78 1
79 2
81 2
82 3
84 2
85 1
86 2
89 1
90 2
91 2
92 1
93 1
96 3
98 3
99 2
100 3
101 1
102 ...

output:

1394

result:

wrong answer 1st lines differ - expected: '1771', found: '1394'

Subtask #3:

score: 0
Time Limit Exceeded

Test #21:

score: 0
Time Limit Exceeded

input:

5000 5000 2000000
1 1
2 1
3 1
4 1
6 1
7 1
8 1
9 1
10 1
11 1
14 1
15 3
17 2
18 2
21 1
22 1
24 1
25 3
27 1
28 2
29 1
30 1
31 1
32 1
33 1
34 1
35 1
37 1
38 1
39 1
40 2
41 2
43 1
45 1
47 1
49 1
50 1
51 1
54 1
55 1
56 1
61 1
62 2
64 1
65 1
67 2
68 2
70 2
72 2
74 1
76 3
79 2
82 4
83 2
84 1
88 1
91 1
92 1
...

output:


result:


Subtask #4:

score: 0
Wrong Answer

Test #31:

score: 21
Accepted
time: 741ms
memory: 39424kb

input:

191299 5000 300000
1 1
5 1
6 2
7 1
8 1
10 1
11 2
12 2
17 1
18 1
19 1
20 1
21 1
22 2
25 1
28 1
29 2
30 1
31 2
34 1
36 1
37 1
38 1
40 1
42 1
43 1
44 1
45 1
47 2
48 1
51 1
53 3
54 2
56 2
58 2
59 2
61 2
63 4
64 2
67 1
68 2
69 2
70 1
72 1
76 1
77 1
78 1
80 2
83 1
84 1
87 1
88 1
89 1
91 2
93 1
95 1
96 1
9...

output:

221
531
204
303
706
486
663
481
540
430
356
588
407
521
570
547
403
316
279
618
128
431
492
453
578
427
643
430
569
233
98
439
698
621
647
549
567
299
627
227
365
338
433
306
547
286
631
581
574
629
667
451
680
140
273
682
607
302
323
697
193
613
557
523
517
702
544
570
355
542
390
196
260
430
296
6...

result:

ok 2476 lines

Test #32:

score: 21
Accepted
time: 744ms
memory: 40780kb

input:

191816 5000 300000
1 74901
2 103360
3 89547
4 67750
5 40186
6 28389
7 24182
8 26076
9 5630
10 26706
11 12730
12 17632
13 7414
14 15422
15 8901
16 10990
17 1835
18 9986
19 10576
20 7349
21 9585
22 730
23 11619
24 955
25 9845
26 10221
27 4553
28 6352
29 543
30 6193
31 8335
32 8880
33 7372
34 2859
35 6...

output:

75673
84156
84079
75931
76804
88017
83643
5724
2566
82368
80605
7466
74
13141
772
25882
19136
28
15335
983
13151
1903
1027
15836
13179
9720
8449
8462
957
6586
41
8812
6679
9142
17162
8172
27
961
8398
6405
1778
93
8437
6931
16952
7357
97
17663
5778
16433
11220
13273
1001
5088
2947
7747
6358
7577
802
...

result:

ok 976 lines

Test #33:

score: 21
Accepted
time: 411ms
memory: 38972kb

input:

193270 5000 300000
22 1
29 1
33 1
40 1
43 1
62 1
63 1
64 1
78 1
80 1
94 1
105 1
106 1
108 1
110 2
120 1
128 1
149 1
203 1
207 1
212 1
234 1
255 2
263 1
266 1
286 1
298 1
300 1
302 1
304 1
313 1
314 2
317 1
327 1
353 1
380 1
384 2
403 1
408 1
426 1
428 1
434 1
442 1
472 1
473 1
476 1
477 1
479 1
490 ...

output:

174
412
199
206
181
217
467
139
18
435
483
412
569
114
317
494
256
149
235
292
371
311
293
565
65
390
528
499
502
338
430
532
36
276
276
123
406
466
151
566
294
498
433
423
228
426
225
474
311
340
91
407
16
59
114
557
56
153
78
415
445
168
531
219
228
395
540
401
212
485
88
549
547
527
146
454
300
1...

result:

ok 4004 lines

Test #34:

score: 0
Wrong Answer
time: 467ms
memory: 40900kb

input:

193095 5000 300000
1 94614
2 123167
3 21362
4 23872
5 16365
6 35594
7 38193
8 7725
9 22330
10 19540
11 5255
12 13478
13 5510
14 6237
15 13251
16 14905
17 1701
18 6700
19 8176
20 10001
21 7572
22 8916
23 10170
24 8570
25 10033
26 7465
27 7099
28 6107
29 8603
30 3776
31 4112
32 4161
33 8181
34 7604
35...

output:

115981
21392
153
1922
2252
134582
94628
155
132469
116186
116104
134576
116221
123833
134594
134175
2358
94782
125418
35909
37321
235
24743
315
26345
35805
24310
16599
25819
24747
37300
125184
29515
21620
2369
18595
35825
123844
123194
24095
8250
1868
19545
10465
8379
13456
7948
15094
13988
15871
22...

result:

wrong answer 366th lines differ - expected: '6618', found: '7128'

Subtask #5:

score: 0
Time Limit Exceeded

Test #41:

score: 0
Time Limit Exceeded

input:

1278949 5000 2000000
4 1
9 1
12 1
13 1
15 2
20 1
21 2
26 1
36 1
39 2
43 1
46 2
59 1
64 1
66 1
71 1
73 1
75 1
78 2
83 1
87 1
89 1
92 1
97 1
103 1
104 1
108 1
111 1
113 1
114 1
117 2
118 1
130 1
137 1
140 1
151 1
152 1
155 1
158 2
163 1
164 1
165 1
168 1
172 1
173 1
183 1
185 1
186 1
192 1
208 1
210 2...

output:


result: