initial commit

This commit is contained in:
ShazidMahsrafi 2023-08-03 02:42:29 +06:00
parent 348898ed9c
commit 0292766232
3 changed files with 100 additions and 1 deletions

View File

@ -0,0 +1,58 @@
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n;
cin>>n;
vector<int>line;
for(int i=0; i<n; ++i)
{
int x;
cin>>x;
line.push_back(x);
}
int min, min_pos, max, max_pos;
min=max_pos=INT_MAX;
max=min_pos=INT_MIN;
for(int i=0; i<n; ++i)
{
if(line[i]>max)
{
max=line[i];
max_pos=i;
}
}
for(int i=n-1; i>=0; --i)
{
if(line[i]<min)
{
min=line[i];
min_pos=i;
}
}
if(max_pos<min_pos)
{
int ans=max_pos+(n-1-min_pos);
cout<<ans<<endl;
}
else
{
int ans=max_pos+(n-1-min_pos)-1;
cout<<ans<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
//cin >> TC;
//cin.ignore();
while (TC--) solve();
}

View File

@ -0,0 +1,40 @@
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n;
cin>>n;
int best,worst,ct=0;
for(int i=0; i<n; ++i)
{
int x;
cin>>x;
if(i==0)
best=worst=x;
if(x<worst)
{
ct++;
worst=x;
}
else if(x>best)
{
ct++;
best=x;
}
}
cout<<ct<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
//cin >> TC;
//cin.ignore();
while (TC--) solve();
}

View File

@ -100,7 +100,8 @@ Feel free to check these codes out.
| 1850C | Word on the Paper | [Question](https://codeforces.com/contest/1850/problem/C) |
| 1851A | Escalator Conversations | [Question](https://codeforces.com/problemset/problem/1851/A) |
| 1851B | Parity Sort | [Question](https://codeforces.com/problemset/problem/1851/B) |
| 1853A | Desorting | [Question](https://codeforces.com/contest/1853/problem/A)
| 1853A | Desorting | [Question](https://codeforces.com/contest/1853/problem/A) |
| 1855A | Dalton the Teacher | [Question](https://codeforces.com/contest/1855/problem/A) |
<br>
</div>