/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 392.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 25ms 532.0 KiB
#4 Accepted 46ms 796.0 KiB
#5 Accepted 181ms 596.0 KiB
#6 Accepted 74ms 572.0 KiB
#7 Accepted 142ms 2.77 MiB
#8 Accepted 139ms 636.0 KiB
#9 Accepted 93ms 1.309 MiB
#10 Accepted 87ms 580.0 KiB
#11 Accepted 304ms 792.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=1e7+1,MOD=1000000007;
typedef long long ll;
#define double long double
#define debug(x) cout<<x<<endl

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        ll s;
        cin>>n>>s;
        vector<ll>v(n);
        for(auto &i:v)cin>>i;
        ll l=1,r=1e12;
        ll answer=-1;
        while(l<=r)
        {
            ll mid=l+(r-l)/2;
            ll sum=0;
            for(auto it:v)
            {
                 sum+=(it/mid);
            }
            if(sum==s)
            {
                answer=mid;
                r=mid-1;
            }
            else if(sum>s)l=mid+1;
            else r=mid-1;
        }
        cout<<answer<<"\n";
    }


    return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1057 Floor Sum
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-22 23:59:35
Judged At
2024-11-11 03:29:44
Judged By
Score
100
Total Time
304ms
Peak Memory
2.77 MiB