QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#772371 | #4571. Even Split | lijunrui08 | WA | 25ms | 5052kb | C++14 | 1.4kb | 2024-11-22 19:04:26 | 2024-11-22 19:04:26 |
Judging History
answer
#include <bits/stdc++.h>
#define fo(i,x,y) for(register int i=(x);i<=(y);i++)
#define de(i,x,y) for(register int i=(x);i>=(y);i--)
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const ll N=1e5+50,M=+50,L=0;
const ll P=0,inf=1e9;
inline ll read(){
ll x=0;bool f=0;char c=getchar();
while(c<'0'||c>'9') f|=(c=='-'),c=getchar();
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
int len,n;
int a[N],lres[N],rres[N];
int check2(int mn,int ans){
int lp=0,rp=0,mx=mn+ans;
fo(i,1,n){
if(rp+mx-1<a[i]) return 0;
if(lp+mn-1>a[i+1]) return 2;
rp=min(rp+mx-1,a[i+1]);
lp=max(lp+mn-1,a[i]);
lres[i]=lp,rres[i]=rp;
}
if(rp<len) return 0;
return 1;
}
int check1(int ans){
int l=0,r=1e9;
while(l<=r){
int mid=(l+r)>>1;
int res=check2(mid,ans);
if(res==1) return mid;
if(res==2) r=mid-1;
else l=mid+1;
}
return 0;
}
signed main(){
len=read(),n=read();
fo(i,1,n) a[i]=read();
a[n+1]=len;
int l=0,r=1e9,ans,mn;
while(l<=r){
int mid=(l+r)>>1,w;
if(w=check1(mid)) ans=mid,mn=w,r=mid-1;
else l=mid+1;
}
check2(mn,ans);
de(i,n-1,1) if(rres[i]-rres[i-1]+1<mn)
rres[i-1]-=mn-(rres[i]-rres[i-1]+1);
fo(i,1,n) printf("%d %d\n",rres[i-1],rres[i]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
6 3 1 3 5
output:
0 2 2 4 4 6
result:
ok Minimal imbalance is 0
Test #2:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
10 2 1 2
output:
0 2 2 10
result:
ok Minimal imbalance is 6
Test #3:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
100 10 14 26 29 31 34 42 44 48 49 68
output:
0 25 25 28 28 31 31 34 34 40 40 43 43 46 46 49 49 68 68 100
result:
ok Minimal imbalance is 29
Test #4:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
100 10 3 42 45 58 69 73 75 78 84 88
output:
0 21 21 42 42 58 58 66 66 70 70 74 74 78 78 84 84 88 88 100
result:
ok Minimal imbalance is 17
Test #5:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
100 10 12 15 24 25 30 45 55 64 80 86
output:
0 12 12 18 18 24 24 30 30 44 44 55 55 64 64 78 78 86 86 100
result:
ok Minimal imbalance is 8
Test #6:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
100 10 10 46 50 57 59 65 76 79 80 90
output:
0 23 23 46 46 55 55 59 59 65 65 72 72 76 76 80 80 90 90 100
result:
ok Minimal imbalance is 19
Test #7:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
100 10 3 5 23 34 36 42 72 81 84 91
output:
0 5 5 20 20 31 31 36 36 42 42 57 57 72 72 84 84 91 91 100
result:
ok Minimal imbalance is 10
Test #8:
score: 0
Accepted
time: 16ms
memory: 5016kb
input:
1000000000 100000 234 521 2233 5010 10213 15298 22181 29569 37404 41370 46544 52606 58851 73956 74520 84776 102335 111406 140442 143688 161164 166404 166924 167716 185557 194472 213634 230507 241622 244806 303238 320282 328153 335228 339419 348046 353158 357866 369691 377344 386277 402535 409037 417...
output:
0 521 521 2233 2233 5010 5010 10213 10213 15298 15298 22181 22181 29569 29569 37404 37404 41370 41370 46544 46544 52606 52606 58851 58851 73956 73956 74520 74520 84776 84776 102335 102335 111406 111406 140442 140442 143688 143688 161164 161164 166404 166404 166924 166924 167716 167716 185557 185557 ...
result:
ok Minimal imbalance is 58553
Test #9:
score: 0
Accepted
time: 25ms
memory: 4996kb
input:
1000000000 100000 9821 14877 29979 35144 54431 56557 59891 72599 75587 121025 122887 131740 134087 139909 173981 174231 204091 207393 215446 224891 231631 234220 250672 259032 262950 267369 273374 273704 277250 291380 313014 315589 320121 338235 340357 351633 353626 362050 374468 376865 414050 41502...
output:
0 14877 14877 29979 29979 35144 35144 54431 54431 56557 56557 59891 59891 72599 72599 75587 75587 121025 121025 122887 122887 131740 131740 134087 134087 139909 139909 173981 173981 174231 174231 204091 204091 207393 207393 215446 215446 224891 224891 231631 231631 234220 234220 250672 250672 259032...
result:
ok Minimal imbalance is 61981
Test #10:
score: 0
Accepted
time: 13ms
memory: 4928kb
input:
1000000000 100000 4042 5042 7422 12401 15821 25327 35801 49225 68723 70197 83123 121581 133929 155017 185876 197018 199980 207705 210442 216704 276702 277043 279595 305639 313551 344704 348884 360171 362803 370412 371572 372244 394028 418234 431550 435436 436500 436512 443397 445171 454725 459496 46...
output:
0 5042 5042 7422 7422 12401 12401 15821 15821 25327 25327 35801 35801 49225 49225 68723 68723 70197 70197 83123 83123 121581 121581 133929 133929 155017 155017 185876 185876 197018 197018 199980 199980 207705 207705 210442 210442 216704 216704 276702 276702 277043 277043 279595 279595 305639 305639 ...
result:
ok Minimal imbalance is 71459
Test #11:
score: 0
Accepted
time: 18ms
memory: 4988kb
input:
1000000000 100000 43366 52388 59798 64732 83545 90296 93651 96518 108948 116125 117723 136287 142824 148549 150819 166180 212247 219196 232566 240175 245719 249847 268918 270244 274579 280579 281630 287075 288837 310333 352501 379088 408527 420992 423438 433780 441930 445186 461742 481610 483437 501...
output:
0 52388 52388 59798 59798 64732 64732 83545 83545 90296 90296 93651 93651 96518 96518 108948 108948 116125 116125 117723 117723 136287 136287 142824 142824 148549 148549 150819 150819 166180 166180 212247 212247 219196 219196 232566 232566 240175 240175 245719 245719 249847 249847 268918 268918 2702...
result:
ok Minimal imbalance is 69674
Test #12:
score: 0
Accepted
time: 22ms
memory: 5016kb
input:
1000000000 100000 859 16443 26041 39093 40232 42927 57255 62982 65646 65743 82046 98650 105881 118156 137616 138932 152665 153210 157351 158576 162315 174381 176862 186878 202710 207484 209207 215144 227450 240723 245533 254405 258204 258230 264973 272941 277526 285536 286094 292720 324584 324887 33...
output:
0 16443 16443 26041 26041 39093 39093 40232 40232 42927 42927 57255 57255 62982 62982 65646 65646 65743 65743 82046 82046 98650 98650 105881 105881 118156 118156 137616 137616 138932 138932 152665 152665 153210 153210 157351 157351 158576 158576 162315 162315 174381 174381 176862 176862 186878 18687...
result:
ok Minimal imbalance is 53927
Test #13:
score: 0
Accepted
time: 14ms
memory: 4928kb
input:
200000 100000 1 2 5 9 13 14 15 18 20 22 23 25 27 28 31 35 37 41 45 46 48 49 51 56 57 60 61 62 63 65 66 67 70 71 72 75 77 78 80 81 82 85 86 91 92 93 95 97 99 100 101 103 104 106 107 108 109 111 112 114 115 117 118 119 120 121 125 127 128 129 130 133 134 135 138 139 140 141 142 147 148 149 150 153 154...
output:
0 2 2 5 5 9 9 13 13 14 14 15 15 18 18 20 20 22 22 23 23 25 25 27 27 28 28 31 31 35 35 37 37 41 41 45 45 46 46 48 48 49 49 51 51 56 56 57 57 60 60 61 61 62 62 63 63 65 65 66 66 67 67 70 70 71 71 72 72 75 75 77 77 78 78 80 80 81 81 82 82 85 85 86 86 91 91 92 92 93 93 95 95 97 97 99 99 100 100 101 101 ...
result:
ok Minimal imbalance is 7
Test #14:
score: 0
Accepted
time: 14ms
memory: 4992kb
input:
200000 100000 9 10 11 13 15 17 19 20 21 22 23 27 28 29 31 32 33 34 37 39 42 43 44 46 47 50 51 52 54 56 58 59 61 62 64 65 67 68 70 71 72 74 75 76 80 82 85 87 88 89 92 93 94 95 97 100 101 104 105 106 107 109 110 111 112 113 114 116 117 122 124 125 128 129 130 133 136 137 139 145 146 147 148 153 157 15...
output:
0 9 9 11 11 13 13 15 15 17 17 19 19 20 20 21 21 22 22 23 23 27 27 28 28 29 29 31 31 32 32 33 33 34 34 37 37 39 39 42 42 43 43 44 44 46 46 47 47 50 50 51 51 52 52 54 54 56 56 58 58 59 59 61 61 62 62 64 64 65 65 67 67 68 68 70 70 71 71 72 72 74 74 75 75 76 76 80 80 82 82 85 85 87 87 88 88 89 89 92 92 ...
result:
ok Minimal imbalance is 8
Test #15:
score: 0
Accepted
time: 14ms
memory: 5052kb
input:
200000 100000 3 4 6 7 12 13 14 16 17 19 20 22 24 28 29 30 32 37 38 39 40 41 43 44 45 48 52 53 54 62 64 67 68 69 70 73 75 79 80 86 89 90 91 92 95 99 100 101 102 106 107 109 110 111 112 113 114 115 119 126 128 129 130 131 132 133 134 135 136 137 139 140 142 145 148 149 151 152 153 154 155 156 157 162 ...
output:
0 4 4 6 6 7 7 12 12 13 13 14 14 16 16 17 17 19 19 20 20 22 22 24 24 28 28 29 29 30 30 32 32 37 37 38 38 39 39 40 40 41 41 43 43 44 44 45 45 48 48 52 52 53 53 54 54 62 62 64 64 67 67 68 68 69 69 70 70 73 73 75 75 79 79 80 80 86 86 89 89 90 90 91 91 92 92 95 95 99 99 100 100 101 101 102 102 106 106 10...
result:
ok Minimal imbalance is 9
Test #16:
score: 0
Accepted
time: 9ms
memory: 4980kb
input:
200000 100000 1 2 4 6 9 10 11 13 14 15 17 18 21 22 23 25 26 27 30 31 34 37 38 40 44 48 49 50 52 54 56 59 60 62 63 64 66 68 69 70 73 74 75 76 77 78 79 80 81 82 85 91 92 93 96 97 99 103 104 105 108 111 113 114 118 119 120 122 125 126 128 129 132 134 135 136 137 138 141 142 143 144 145 146 147 148 149 ...
output:
0 2 2 4 4 6 6 9 9 10 10 11 11 13 13 14 14 15 15 17 17 18 18 21 21 22 22 23 23 25 25 26 26 27 27 30 30 31 31 34 34 37 37 38 38 40 40 44 44 48 48 49 49 50 50 52 52 54 54 56 56 59 59 60 60 62 62 63 63 64 64 66 66 68 68 69 69 70 70 73 73 74 74 75 75 76 76 77 77 78 78 79 79 80 80 81 81 82 82 85 85 91 91 ...
result:
ok Minimal imbalance is 7
Test #17:
score: 0
Accepted
time: 14ms
memory: 4996kb
input:
200000 100000 3 6 7 9 10 11 13 16 17 19 21 22 23 24 26 27 29 33 36 39 40 41 42 43 44 45 46 48 49 51 52 57 58 60 61 64 65 66 67 70 71 73 75 76 79 81 82 84 85 89 90 91 94 95 96 97 98 101 103 104 105 106 111 113 120 124 126 132 133 135 140 141 144 146 149 150 151 154 155 156 157 158 161 162 164 168 170...
output:
0 6 6 7 7 9 9 10 10 11 11 13 13 16 16 17 17 19 19 21 21 22 22 23 23 24 24 26 26 27 27 29 29 33 33 36 36 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 48 48 49 49 51 51 52 52 57 57 58 58 60 60 61 61 64 64 65 65 66 66 67 67 70 70 71 71 73 73 75 75 76 76 79 79 81 81 82 82 84 84 85 85 89 89 90 90 91 9...
result:
ok Minimal imbalance is 9
Test #18:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
2 1 1
output:
0 2
result:
ok Minimal imbalance is 0
Test #19:
score: 0
Accepted
time: 12ms
memory: 5016kb
input:
999934479 100000 1347 7016 13646 16374 19258 25729 29070 35355 41999 43931 48141 53449 57471 62160 70011 71302 76850 80099 87156 90531 94830 100986 107127 109682 116557 117400 122935 126876 133002 136999 141021 145873 153443 157968 159027 164692 168204 172909 178889 182471 190653 196019 196899 20187...
output:
0 4670 4670 9340 9340 14010 14010 18680 18680 23350 23350 28020 28020 32690 32690 37360 37360 42030 42030 46700 46700 51370 51370 56040 56040 60710 60710 65380 65380 70050 70050 74720 74720 79390 79390 84060 84060 88730 88730 93400 93400 98070 98070 102740 102740 107410 107410 112080 112080 116750 1...
result:
ok Minimal imbalance is 10703
Test #20:
score: 0
Accepted
time: 8ms
memory: 5016kb
input:
999938652 100000 10872 12876 29327 39905 54962 63774 68095 78723 92667 103162 118715 125653 139032 153559 161457 172997 187452 196302 207806 212033 227157 235734 252930 255857 273858 283859 294767 305386 314251 327619 340534 351036 361521 370216 387250 397101 405113 413617 430570 435277 453829 45923...
output:
0 11095 11095 22190 22190 33285 33285 44380 44380 55475 55475 66570 66570 77665 77665 88760 88760 99855 99855 110950 110950 122045 122045 133140 133140 144235 144235 155330 155330 166425 166425 177520 177520 188615 188615 199710 199710 210805 210805 221900 221900 232995 232995 244090 244090 255185 2...
result:
ok Minimal imbalance is 2747
Test #21:
score: -100
Wrong Answer
time: 6ms
memory: 4920kb
input:
999927360 100000 2777 15328 31200 39979 52649 68523 69247 81294 94805 108866 125092 131743 137506 150523 167769 178287 191991 200932 213245 219533 237155 241318 253312 270831 281458 288670 303989 316622 326818 337655 345316 354786 372518 382283 399600 408565 413618 428562 435378 453307 460485 474419...
output:
0 11422 11422 22844 22844 34266 34266 45688 45688 57110 57110 68532 68532 79954 79954 91376 91376 102798 102798 114220 114220 125642 125642 137064 137064 148486 148486 159908 159908 171330 171330 182752 182752 194174 194174 205596 205596 217018 217018 228440 228440 239862 239862 251284 251284 262706...
result:
wrong answer Jury found better solution (j=2840 vs p=5934)