QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#650801#8284. Cats and Fishshiqiaqiaya#TL 1ms3764kbC++201.2kb2024-10-18 16:33:182024-10-18 16:33:19

Judging History

This is the latest submission verdict.

  • [2024-10-18 16:33:19]
  • Judged
  • Verdict: TL
  • Time: 1ms
  • Memory: 3764kb
  • [2024-10-18 16:33:18]
  • Submitted

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

output:


result: