QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#651639#6135. Booksucup-team5217#WA 78ms3972kbC++23896b2024-10-18 17:53:402024-10-18 17:53:41

Judging History

This is the latest submission verdict.

  • [2024-10-18 17:53:41]
  • Judged
  • Verdict: WA
  • Time: 78ms
  • Memory: 3972kb
  • [2024-10-18 17:53:40]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve(void) {
    int n,m;
    cin>>n>>m;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)   cin>>a[i];
    const ll maxn=1e16;
    ll lo=0,ro=1e16;
    auto check=[&](ll x)->ll {
        ll ans=0;
        for(int i=1;i<=n;i++){
            if(x>=a[i]) {ans++;x-=a[i];}
        }
        return ans;
    };
    while(lo<ro){
        ll mid=(lo+ro)/2;
        ll num=check(mid);
        if(num>m)  ro=mid;
        else lo=mid+1;
    }
    if(lo==maxn) cout<<"Richman\n";
    else if(lo==0||check(lo-1)!=m)   cout<<"Impossible\n";
    else cout<<lo-1<<'\n';   
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);

    int _ = 1;
    cin >> _;
    while (_--) solve();

    return 0;
}
/*
 4
 4 2
 1 2 4 8
 4 0
 100 99 98 97
 2 2
 10000 10000
 5 3
 0 0 0 0 1
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3672kb

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: 78ms
memory: 3972kb

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
38
80
Richman
97
460
Richman
24
142
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
356
Richman
Richman
60
312
62
276
Richman
67
R...

result:

wrong answer 5th lines differ - expected: '192', found: '38'