QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#363096 | #4571. Even Split | mc020207 | WA | 0ms | 3716kb | C++17 | 1.7kb | 2024-03-23 18:17:30 | 2024-03-23 18:17:31 |
Judging History
answer
#include<bits/stdc++.h>
#define MAXN 100010
#define INF 1000000010
#define MOD 1000000007
#define LL long long
#define LLL __int128_t
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
int tot,n;
int a[MAXN];
bool checkl(int len){
int now=0;
For(i,1,n){
now=max(now+len,a[i]+1);
if (now>a[i+1]) return false;
}
return now<=tot;
}
int solvel(){
int l=1,r=tot,ans=0;
while (l<=r){
int mid=l+r>>1;
if (checkl(mid)) l=mid+1,ans=mid;
else r=mid-1;
}
return ans;
}
bool checkr(int len){
int now=0;
For(i,1,n){
now=min(now+len,a[i+1]);
if (now<=a[i]) return false;
}
return now>=tot;
}
typedef pair<int,int> pii;
pii li[MAXN];
pii ans[MAXN];
int solver(){
int l=1,r=tot,ans=0;
while (l<=r){
int mid=l+r>>1;
if (checkr(mid)) r=mid-1,ans=mid;
else l=mid+1;
}
return ans;
}
void Main(){
cin>>tot>>n;
For(i,1,n) cin>>a[i];
a[0]=0,a[n+1]=tot;
int l=solvel(),r=solver();
// cout<<l<<" "<<r<<"\n";
int now=0;
For(i,1,n){
now=max(now+l,a[i]+1);
li[i].first=now;
}
now=0;
For(i,1,n){
now=min(now+r,a[i+1]);
li[i].second=now;
}
now=tot;
ans[n].second=tot;
Rof(i,n-1,1){
now=max(li[i].first,now-r);
ans[i+1].first=ans[i].second=now;
}
ans[1].first=0;
For(i,1,n) cout<<ans[i].first<<" "<<ans[i].second<<"\n";
}
int main(){
std::ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T=1;/* cin>>T; */
while (T--) Main();
}
/*
6 3
1 3 5
10 2
1 2
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3696kb
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: 3716kb
input:
10 2 1 2
output:
0 2 2 10
result:
ok Minimal imbalance is 6
Test #3:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
100 10 14 26 29 31 34 42 44 48 49 68
output:
0 15 15 27 27 30 30 33 33 36 36 43 43 46 46 49 49 68 68 100
result:
ok Minimal imbalance is 29
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3692kb
input:
100 10 3 42 45 58 69 73 75 78 84 88
output:
0 21 21 43 43 47 47 59 59 70 70 74 74 78 78 82 82 86 86 100
result:
wrong answer Jury found better solution (j=17 vs p=18)