QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#650801 | #8284. Cats and Fish | shiqiaqiaya# | TL | 1ms | 3764kb | C++20 | 1.2kb | 2024-10-18 16:33:18 | 2024-10-18 16:33:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
int m,n,x;
const int maxn = 1e5+10 ;
vector<int> a(maxn) ;
struct node{
int id,c ;
bool operator<(const node y)const
{
if(c==y.c)
return a[id] > a[y.id] ;
return c>y.c ;
}
};
signed main(){
cin >> m >> n >> x ;
priority_queue<node>q ;
for(int i = 1 ; i <= n ; i++)
{
int y ; cin >> y ; a[i] = y ;
q.push((node{i,y})) ;
}
if(m<n){
priority_queue<node>q2 ;
for(int i = 1 ; i <= m ; i++)
q2.push(q.top()),q.pop() ;
q = q2 ;
}
int ans = 0 ;
int rest = max(m-n,0ll) ;
while(1){
node now = q.top() ;
// cout<<now.id<<" "<<now.c<<" "<<a[now.id]<<endl ;
if(now.c>x)break ;
q.pop() ;
if(rest<=0){
continue ;
}
rest-- ;
now.c+=a[now.id] ;
q.push(now) ;
}
ans = q.size() ;
while(!q.empty()){
node now = q.top() ;
if(now.c - a[now.id]==x)ans-- , rest++ ;
q.pop() ;
}
cout<<rest<<" "<<ans<<endl ;
return 0 ;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
input:
2 1 1 1
output:
1 0
result:
ok 2 number(s): "1 0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
8 3 5 1 3 4
output:
0 1
result:
ok 2 number(s): "0 1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
4 5 1 5 4 3 2 1
output:
0 3
result:
ok 2 number(s): "0 3"
Test #4:
score: -100
Time Limit Exceeded
input:
1 1 10 1