initial commit

This commit is contained in:
ShazidMahsrafi 2023-10-13 18:29:05 +06:00
parent b608b98aef
commit 86f81c53e8

View File

@ -52,26 +52,41 @@ bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i+
void solve() void solve()
{ {
int n; int n,k,x;
cin>>n; cin>>n>>k>>x;
vector<int>str; if(n<k || x+1<k)
vector<int>end;
for(int i=0; i<n; ++i)
{ {
int x,y; cout<<-1<<nl;
cin>>x>>y; return;
str.pb(x);
end.pb(y);
} }
for(int i=1; i<n; ++i) int i=0,ct=0,sum=0;
while(i<k && ct<n)
{ {
if(str[i]>=str[0] && end[i]>=end[0]) sum+=i;
i++;
ct++;
}
if(ct<n)
{
if(x!=k)
{ {
cout<<-1<<nl; while(ct<n)
return; {
sum+=x;
ct++;
}
}
else if(x==k)
{
x--;
while(ct<n)
{
sum+=x;
ct++;
}
} }
} }
cout<<str[0]<<nl; cout<<sum<<nl;
} }
int main() int main()