Skip to content

Commit 8d275e2

Browse files
author
shubham4756
authored
Create 339.cpp
1 parent 969e0c5 commit 8d275e2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Codeforces/339.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
link. https://codeforces.com/contest/339/problem/B
3+
*/
4+
5+
#include<bits/stdc++.h>
6+
using namespace std;
7+
int main()
8+
{ unsigned long long int n,m;
9+
cin>>n>>m;
10+
unsigned long long int pos=1,sum=0,a[m],num=0;
11+
for(long int i=0;i<m;i++)
12+
{
13+
cin>>a[i];
14+
if(i!=0)
15+
{
16+
if(a[i-1]>a[i])
17+
num++;
18+
}
19+
}
20+
cout<<(num*n)+a[m-1]-1;
21+
return 0;
22+
}

0 commit comments

Comments
 (0)