QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#492915 | #6135. Books | Ink_bai | WA | 57ms | 4612kb | C++14 | 1.2kb | 2024-07-26 17:11:10 | 2024-07-26 17:11:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 100005
int a[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin>>t;
while(t--)
{
int n,m;
cin>>n>>m;
int c=0;
int mini=0x3f3f3f3f;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]==0)c++;
if(a[i]!=0)
mini=min(a[i],mini);
}
if(n==m)puts("Richman");
else if(c>m) puts("Impossible");
else
{
if(m==0||c==m) printf("%lld\n",mini-1);
else
{
int ans=0;
int pos;
for(int i=1;i<=n;i++)
{
if(a[i]==0)continue;
if(c<m)ans+=a[i],c++;
if(c==m)
{
pos=i;
break;
}
}
mini=0x3f3f3f3f;
for(int j=pos+1;j<=n;j++)
{
if(a[j]!=0)mini=min(mini,a[j]);
}
ans+=mini-1;
cout<<ans<<endl;
}
}
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3900kb
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: 57ms
memory: 4612kb
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:
99999999999999 192 80 460 163 65 450 98 349 513 161 297 147 274 160 58 130 175 65 247 356 312 276 245 62 43 390 315 272 103 97 264 101 60 105 180 196 103 211 35 303 102 145 82 203 130 346 195 164 78 79 63 92 254 69 54 239 433 85 57 347 201 94 68 430 389 219 199 167 243 166 55 238 136 138 205 423 222...
result:
wrong answer 1st lines differ - expected: '1', found: '99999999999999'