Submission #3010246


Source Code Expand

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll w[111111];
ll d[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n,k; cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>d[i];
	}
	ll lo = 1; ll hi = ll(4e18);
	ll ans=0;
	while(lo<=hi)
	{
		ll mid=(lo+hi)>>1;
		ll cnt=0;
		for(int i=0;i<n;i++)
		{
			if(w[i]<=mid)
			{
				cnt+=1+(mid-w[i])/d[i];
				cnt=min(cnt,k);
			}
		}
		if(cnt>=k)
		{
			ans=mid;
			hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	cout<<ans<<'\n';
}

Submission Info

Submission Time
Task C - Garden
User fxt
Language C++ (GCC 5.4.1)
Score 100
Code Size 1081 Byte
Status AC
Exec Time 93 ms
Memory 1792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 23
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 92 ms 1792 KB
b06 AC 91 ms 1792 KB
b07 AC 92 ms 1792 KB
b08 AC 93 ms 1792 KB
b09 AC 92 ms 1792 KB
b10 AC 93 ms 1792 KB
b11 AC 33 ms 1792 KB
b12 AC 36 ms 1792 KB
b13 AC 40 ms 1792 KB
b14 AC 47 ms 1792 KB
b15 AC 33 ms 1792 KB
b16 AC 36 ms 1792 KB
b17 AC 41 ms 1792 KB
b18 AC 50 ms 1792 KB
b19 AC 31 ms 1792 KB
b20 AC 35 ms 1792 KB
b21 AC 38 ms 1792 KB
b22 AC 43 ms 1792 KB
b23 AC 60 ms 1792 KB