QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#526270 | #6135. Books | FLtheLeatherman | WA | 35ms | 4568kb | C++14 | 1.3kb | 2024-08-21 12:51:32 | 2024-08-21 12:51:33 |
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;
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);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
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: 35ms
memory: 4568kb
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 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 276 Richman 67 R...
result:
wrong answer 12th lines differ - expected: '163', found: '90'