QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623699#9423. Gold MedalDevid_GuaZi#RE 1ms5624kbC++17980b2024-10-09 13:45:272024-10-09 13:45:28

Judging History

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

  • [2024-10-09 13:45:28]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5624kb
  • [2024-10-09 13:45:27]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
#define int long long
using namespace std;


typedef long long ll;
typedef  pair<int,int> PII;
const int N = 2e5+5;
//string F[N][100005];
//int val[30];

int t=1;int n=0,m=0;
int c[N];
int x,k[N];
int l[N];
//unsigned long long thash(string s1){
//	int len=s1.length();
//	unsigned long long res=(s1[0]-'a')+1;
//	for(int i=1;i<len;i++){
//		res=res*499+s1[i]-'a'+1;
//	}
//	return res;
//}

void solve(){
	cin>>n>>m;int ans=0;int out=0;
	for(int i=0;i<n;i++){
		cin>>c[i];
		l[i]=c[i]%m;
		out+=c[i]/m;
	}
	cin>>ans;
	sort(l,l+n,greater<int>());
	int j=0;
	if(l[0]==0){
		cout<<ans/m+out<<endl;
		return;
	}
	while(ans>0){
		ans-=m-l[j];
		if(ans<0) break;
		j++;
	}
	cout<<out+j<<endl;;

}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cin>>t;
	int i=1;
	while(t--){
		//cout<<"Case #"<<i<<": "<<endl;
		solve();
		i++;
	}
} 

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5624kb

input:

2
3 10
239 141 526
6
2 1
300 100
1000

output:

91
1400

result:

ok 2 lines

Test #2:

score: -100
Runtime Error

input:

100
39 88
746 86884 628655 868 87506 46761498 3338 91952768 312 9712 5277106 2263554 246545 98849 91459 6 5506 4 17626 5984050 32079 10 7672277 8104250 62 8976 866448 1 4 62240996 93128 181 6 9 5 175665 9 7680943 81
239822
9 200383
53147 17 82509 3 617847780 418677763 5402536 16 38253558
79857
66 60...

output:


result: