QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623785 | #9423. Gold Medal | Devid_GuaZi# | RE | 0ms | 3588kb | C++17 | 1.0kb | 2024-10-09 14:00:00 | 2024-10-09 14:00:01 |
Judging History
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){
if(l[j]==0) {
cout<<ans/m+out+j<<endl;
}
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++;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
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:
2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734453 2734...