Submission #61822706
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+100;
int n;
ll m,p[N],ans;
priority_queue<ll,vector<ll>,greater<ll> >q;
bool check(ll x){
ll sum=0;
for(int i=1;i<=n;i++){
ll k=(x/p[i]+1)/2;
if((__int128)k*k*p[i]>m)return 0;
sum+=k*k*p[i];
if(sum>m)return 0;
}
return sum<=m;
}
signed main()
{
// freopen("q.in","r",stdin);
// freopen("q.out","w",stdout);
scanf("%d%lld",&n,&m);
for(int i=1;i<=n;i++){
scanf("%lld",&p[i]);
}
ll l=0,r=m;
while(l<r){
ll mid=(l+r+1)>>1;
if(check(mid))l=mid;
else r=mid-1;
}
// cout<<l<<endl;
for(int i=1;i<=n;i++){
ll k=(l/p[i]+1)/2;
q.push((2*k+1)*p[i]);
m-=k*k*p[i];
ans+=k;
}
// cerr<<m<<endl;
while(!q.empty()){
if(q.top()<=m){
m-=q.top();
ans++;
}
q.pop();
}
cout<<ans;
}
Submission Info
Submission Time |
|
Task |
E - Square Price |
User |
Abnormal123 |
Language |
C++ 20 (gcc 12.2) |
Score |
475 |
Code Size |
845 Byte |
Status |
AC |
Exec Time |
70 ms |
Memory |
7052 KB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d%lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%lld",&p[i]);
| ~~~~~^~~~~~~~~~~~~~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
475 / 475 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
1 ms |
3736 KB |
00_sample_01.txt |
AC |
1 ms |
3744 KB |
01_random_00.txt |
AC |
69 ms |
6892 KB |
01_random_01.txt |
AC |
70 ms |
6916 KB |
01_random_02.txt |
AC |
69 ms |
6804 KB |
01_random_03.txt |
AC |
69 ms |
6888 KB |
01_random_04.txt |
AC |
70 ms |
7052 KB |
01_random_05.txt |
AC |
68 ms |
6944 KB |
01_random_06.txt |
AC |
69 ms |
6960 KB |
01_random_07.txt |
AC |
69 ms |
6912 KB |
01_random_08.txt |
AC |
70 ms |
7052 KB |
01_random_09.txt |
AC |
70 ms |
6952 KB |
01_random_10.txt |
AC |
7 ms |
3852 KB |
01_random_11.txt |
AC |
61 ms |
6732 KB |
01_random_12.txt |
AC |
5 ms |
4040 KB |
01_random_13.txt |
AC |
13 ms |
4220 KB |
01_random_14.txt |
AC |
42 ms |
5316 KB |
01_random_15.txt |
AC |
67 ms |
6888 KB |
01_random_16.txt |
AC |
33 ms |
4956 KB |
01_random_17.txt |
AC |
21 ms |
4500 KB |
01_random_18.txt |
AC |
52 ms |
6548 KB |
01_random_19.txt |
AC |
59 ms |
6696 KB |
01_random_20.txt |
AC |
31 ms |
6900 KB |
01_random_21.txt |
AC |
48 ms |
6944 KB |
01_random_22.txt |
AC |
1 ms |
3632 KB |
01_random_23.txt |
AC |
1 ms |
3704 KB |