QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627017#9423. Gold Medaldnyh#Compile Error//C++14775b2024-10-10 14:28:402024-10-10 14:28:41

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 14:28:41]
  • 评测
  • [2024-10-10 14:28:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef std::pair<int,int>pii;
#define N 300100
int a[N],b[N];
int t;

void solve(){
	int n,k;
	cin>>n>>k;

	for(int i=1;i<=n;i++){
         cin>>a[i];
	}
	int m;
	cin>>m;

	if(k==1){
           int ans=m;
           for(int i=1;i<=n;i++) ans+=a[i];
           cout<<ans<<endl;
           return ;
	}
	int res=0;
	for(int i=1;i<=n;i++) res+=(a[i]/k),b[i]=a[i]%k; 
	sort(b+1,b+1+n,greater());
    for(int i=1;i<=n;i++){
    	if(b[i]+m<k||m<0) break;
    	res++;
    	m-=k-b[i];
    	
    }
    cout<<res<<endl;
}
signed main(){  
    std::ios::sync_with_stdio(false); 
    std::cin.tie(nullptr);   
    cin>>t;
    while(t--){
    	solve();
    }

    return 0 ;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:27:31: error: missing template arguments before ‘(’ token
   27 |         sort(b+1,b+1+n,greater());
      |                               ^