Submission #61825675
Source Code Expand
Copy
#include<bits/stdc++.h>using namespace std;#define int long long#define debug() cout<<"come on"<<'\n'struct edge{int p,k;bool operator <(const edge &x) const{return (2*k-1)*p!=(2*x.k-1)*x.p?(2*k-1)*p>(2*x.k-1)*x.p:k<x.k;}};int n,m,mm,ans;priority_queue<edge> pq;signed main(){cin>>n>>m;for(int i=1;i<=n;i++){int x;cin>>x;pq.push((edge){x,1});}while(mm<=m){edge x=pq.top();
#include<bits/stdc++.h> using namespace std; #define int long long #define debug() cout<<"come on"<<'\n' struct edge{ int p,k; bool operator <(const edge &x) const{ return (2*k-1)*p!=(2*x.k-1)*x.p?(2*k-1)*p>(2*x.k-1)*x.p:k<x.k; } }; int n,m,mm,ans; priority_queue<edge> pq; signed main(){ cin>>n>>m; for(int i=1;i<=n;i++){ int x; cin>>x; pq.push((edge){x,1}); } while(mm<=m){ edge x=pq.top(); pq.pop(); if(x.p*(2*x.k-1)+mm>m)break; mm+=x.p*(2*x.k-1); x.k++,ans++; pq.push(x); } cout<<ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Square Price |
User | dulf2024 |
Language | C++ 20 (gcc 12.2) |
Score | 0 |
Code Size | 561 Byte |
Status | TLE |
Exec Time | 2210 ms |
Memory | 7380 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 3476 KB |
00_sample_01.txt | AC | 1 ms | 3480 KB |
01_random_00.txt | TLE | 2210 ms | 7300 KB |
01_random_01.txt | TLE | 2208 ms | 7352 KB |
01_random_02.txt | TLE | 2207 ms | 7296 KB |
01_random_03.txt | TLE | 2207 ms | 7308 KB |
01_random_04.txt | TLE | 2208 ms | 7380 KB |
01_random_05.txt | TLE | 2210 ms | 7348 KB |
01_random_06.txt | TLE | 2207 ms | 7364 KB |
01_random_07.txt | TLE | 2207 ms | 7308 KB |
01_random_08.txt | TLE | 2207 ms | 7252 KB |
01_random_09.txt | TLE | 2207 ms | 7272 KB |
01_random_10.txt | AC | 988 ms | 3732 KB |
01_random_11.txt | TLE | 2208 ms | 7340 KB |
01_random_12.txt | AC | 999 ms | 3596 KB |
01_random_13.txt | AC | 1747 ms | 4260 KB |
01_random_14.txt | TLE | 2167 ms | 5192 KB |
01_random_15.txt | TLE | 2207 ms | 7344 KB |
01_random_16.txt | TLE | 2207 ms | 5224 KB |
01_random_17.txt | TLE | 2207 ms | 4352 KB |
01_random_18.txt | TLE | 2207 ms | 7332 KB |
01_random_19.txt | TLE | 2207 ms | 7352 KB |
01_random_20.txt | TLE | 2207 ms | 7332 KB |
01_random_21.txt | AC | 1591 ms | 7256 KB |
01_random_22.txt | AC | 2 ms | 3528 KB |
01_random_23.txt | TLE | 2039 ms | 3408 KB |