ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#385 | #53. 「NOIP2012」借教室 | j27eGU | 100 | 1803ms | 26780kb | C++23 | 876b | 2025-04-23 11:33:20 | 2025-04-23 11:33:21 |
answer
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1000005;
int n,m,cf[MAXN],re[MAXN],ne[MAXN],d[MAXN],l[MAXN],r[MAXN];
bool check(int t)
{
memset(cf,0,sizeof(cf));
for(int i=1;i<=t;i++)
{
cf[l[i]]+=d[i];
cf[r[i]+1]-=d[i];
}
for(int i=1;i<=n;i++)
{
ne[i]=ne[i-1]+cf[i];
if(ne[i]>re[i])
return false;
}
return true;
}
int main()
{
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>re[i];
for(int i=1;i<=m;i++)
cin>>d[i]>>l[i]>>r[i];
int be=1,en=m;
if(check(m))
{
cout<<0;
return 0;
}
while(be<en)
{
int mid=be+(en-be)/2;
if(check(mid))
be=mid+1;
else
en=mid;
}
printf("-1\n%d",be);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 3ms
memory: 15352kb
input:
10 10 42323424 633675939 990396626 965164370 965164370 965164370 972489810 619351082 619351082 0 586...
output:
-1 6
result:
ok 2 tokens
Test #2:
score: 5
Accepted
time: 3ms
memory: 15096kb
input:
10 10 225657656 994645291 999202796 999202796 999202796 942745784 962612348 842542128 73554493 49116...
output:
-1 5
result:
ok 2 tokens
Test #3:
score: 5
Accepted
time: 4ms
memory: 15256kb
input:
1000 1000 2 86 107 107 111 138875 10058344 10058360 10058372 10058418 10058422 10362857 10362862 103...
output:
-1 1
result:
ok 2 tokens
Test #4:
score: 5
Accepted
time: 9ms
memory: 15024kb
input:
1000 1000 184970508 184970508 184970513 650474134 660056159 660056163 789188052 789188054 660109241 ...
output:
-1 299
result:
ok 2 tokens
Test #5:
score: 5
Accepted
time: 2ms
memory: 15124kb
input:
1000 1000 3 4 6285640 6288442 348276846 503924960 503924965 503924965 503924969 504230439 162242037 ...
output:
-1 100
result:
ok 2 tokens
Test #6:
score: 5
Accepted
time: 8ms
memory: 14884kb
input:
1000 1000 4 8 9 10 13 2014542 2014546 2014549 2014551 2014554 2014564 6058453 6058454 6058455 605845...
output:
-1 450
result:
ok 2 tokens
Test #7:
score: 5
Accepted
time: 19ms
memory: 17336kb
input:
80000 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
-1 8
result:
ok 2 tokens
Test #8:
score: 5
Accepted
time: 25ms
memory: 17260kb
input:
100000 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
0
result:
ok "0"
Test #9:
score: 5
Accepted
time: 37ms
memory: 17700kb
input:
50000 50000 16 36 72 75 82 83 86 96 98 107 112 117 148 156 158 179 297 300 302 307 311 320 322 322 3...
output:
-1 10827
result:
ok 2 tokens
Test #10:
score: 5
Accepted
time: 56ms
memory: 19256kb
input:
80000 80000 44 44 2174 2180 2185 2244 2244 2244 2244 89746 89751 89757 89771 89784 89789 89789 89813...
output:
-1 61233
result:
ok 2 tokens
Test #11:
score: 5
Accepted
time: 69ms
memory: 22000kb
input:
100000 100000 13 14 14 37 38 45 73 241 256 264 267 505 511 527 534 536 616 653 657 660 684 1155 1155...
output:
-1 90040
result:
ok 2 tokens
Test #12:
score: 5
Accepted
time: 70ms
memory: 16004kb
input:
100000 100000 23 37 38 40 47 49 271 477 980045 980062 980066 980066 980108 980143 980146 980153 9801...
output:
-1 92041
result:
ok 2 tokens
Test #13:
score: 5
Accepted
time: 64ms
memory: 19580kb
input:
100000 100000 17 17 21 27 32 37 39 46 73 109 118 18392420 18392420 18392432 18392469 18392469 183924...
output:
-1 61524
result:
ok 2 tokens
Test #14:
score: 5
Accepted
time: 72ms
memory: 16304kb
input:
100000 100000 6 11 39 39 40 40 48 59 73 77 85 88 11761965 11761965 11761969 11761970 11762014 117620...
output:
-1 42857
result:
ok 2 tokens
Test #15:
score: 5
Accepted
time: 106ms
memory: 20300kb
input:
200000 200000 7 9 76 77 86 86 160 160 581 591 604 348037292 348037304 348037306 348037325 348037328 ...
output:
-1 93084
result:
ok 2 tokens
Test #16:
score: 5
Accepted
time: 188ms
memory: 20728kb
input:
300000 300000 3 4 154 162 194 210 217 221 255 265 268 270 275 303 307 323 323 323 344 385 387 392 39...
output:
-1 206829
result:
ok 2 tokens
Test #17:
score: 5
Accepted
time: 217ms
memory: 24332kb
input:
400000 400000 0 2 10 13 37 45 66 81 82 114 466 468 609 614 2068 2071 2077 2079 2084 2090 2101 2105 2...
output:
-1 128658
result:
ok 2 tokens
Test #18:
score: 5
Accepted
time: 269ms
memory: 26780kb
input:
500000 500000 33 35 36 36 46 46 59 87 92 100 108 126 155 180 185 185 185 5753 6792348 6792353 679236...
output:
-1 282993
result:
ok 2 tokens
Test #19:
score: 5
Accepted
time: 271ms
memory: 26668kb
input:
500000 500000 10 11 13 21 24 43 48 54 57 57 60 60 61 78 110 114 115 119 121 131 135 143 143 162 169 ...
output:
-1 178910
result:
ok 2 tokens
Test #20:
score: 5
Accepted
time: 311ms
memory: 26656kb
input:
500000 500000 0 0 5 17 29 29 53 59 60 61 84 85 10733 10739 10794 10870 10870 10876 10878 10907 11044...
output:
-1 445564
result:
ok 2 tokens