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;
cin>>x>>y;
str.pb(x);
end.pb(y);
}
for(int i=1; i<n; ++i)
{
if(str[i]>=str[0] && end[i]>=end[0])
{ {
cout<<-1<<nl; cout<<-1<<nl;
return; return;
} }
int i=0,ct=0,sum=0;
while(i<k && ct<n)
{
sum+=i;
i++;
ct++;
} }
cout<<str[0]<<nl; if(ct<n)
{
if(x!=k)
{
while(ct<n)
{
sum+=x;
ct++;
}
}
else if(x==k)
{
x--;
while(ct<n)
{
sum+=x;
ct++;
}
}
}
cout<<sum<<nl;
} }
int main() int main()