QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#526273 | #6135. Books | FLtheLeatherman | WA | 31ms | 4504kb | C++14 | 1.5kb | 2024-08-21 12:52:47 | 2024-08-21 12:52:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
inline int read(){
char ch=getchar();
int num=0,f=1;
while(!isdigit(ch)){
if(ch=='-')f=-1;
ch=getchar();
}
while(isdigit(ch)){
num=num*10+ch-'0';
ch=getchar();
}
return f>0?num:-num;
}
const int MAXN=100010;
int n,m;
int a[MAXN];
bool check(int val){
int cnt=0;
rep(i,1,n){
if(val>=a[i]){
cnt++;
val-=a[i];
}
}
return cnt<=m;
}
signed main(){
//freopen("J.in","r",stdin);
int T;
cin>>T;
int cnt=0;
while(T--){
n=read(),m=read();
int s=0;
rep(i,1,n){
a[i]=read();
s+=a[i];
}
if(!check(0)){
puts("Impossible");
continue;
}
else if(m==n){
puts("Richman");
continue;
}
int l=0,r=s;
int ans=s;
while(l<=r){
int mid=(l+r)/2;
if(check(mid)){
l=mid+1;
ans=mid;
}
else r=mid-1;
}
printf("%lld\n",ans);
cnt++;
if(cnt==12){
cout<<n<<' '<<m<<endl;
rep(i,1,n){
cout<<a[i]<<' ';
}
cout<<endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
input:
4 4 2 1 2 4 8 4 0 100 99 98 97 2 2 10000 10000 5 3 0 0 0 0 1
output:
6 96 Richman Impossible
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 31ms
memory: 4504kb
input:
10012 1 0 2 3 2 0 1 0 2 1 0 0 100000 99999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...
output:
1 0 Impossible 99999999999999 192 80 Richman 97 460 Richman 24 90 98 30 15 4 0 99 16 27 64 Richman Richman Richman 65 Richman Richman 450 24 44 349 34 513 28 99 238 Richman Richman Richman 66 274 2 160 76 58 91 71 3 Richman 125 32 15 Richman 21 26 Richman 7 Richman 247 300 Richman Richman 60 312 62...
result:
wrong answer 12th lines differ - expected: '163', found: '90'