/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 480.0 KiB
#3 Accepted 26ms 572.0 KiB
#4 Accepted 47ms 796.0 KiB
#5 Accepted 183ms 600.0 KiB
#6 Accepted 74ms 584.0 KiB
#7 Accepted 144ms 2.816 MiB
#8 Accepted 141ms 636.0 KiB
#9 Accepted 93ms 1.316 MiB
#10 Accepted 86ms 584.0 KiB
#11 Accepted 303ms 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-23 00:05:29
Judged At
2024-11-11 03:29:43
Judged By
Score
100
Total Time
303ms
Peak Memory
2.816 MiB