For this Question: Sara is playing a game in which she is fighting with N monsters who are standing in a line. Each monster has some HP with him. At every second, Sara hits the monster standing at the front of the line. When the monster gets hit his HP decreases by 1 and he goes to the end of the line(which happens instantaneously). 

For example:
if the monster's health are (1, 3, 2)
After 1st hit:- 3, 2 (monster at index 0 dies)
After 2nd hit:- 2, 2
After 3rd hit:- 2, 1
After 4th hit:- 1, 1
After 5th hit:- 1(monster who was originally at index 2 dies)
After 6th hit:- (monster who was originally at index 1 dies)

Now Sara who keeps track of the time wants to know the time when the Kth(0 indexing) monster dies(A monster dies when his HP hits 0).The first line of input contains two space separated integers depicting N and K. 
The next line contains N space separated integers depicting the HP of every monster.

<b>Constraints:-</b>
1 <= N <= 100
0 <= K < N
1 <= HP <= 100Print the time when the Kth monster dies.Sample Input:-
3 2
1 3 2

Sample Output:-
5

Sample Input:-
4 0
5 1 1 1

Sample Output:-
8, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
#define int long long

int solve(vector<int> a, int k){

        int answer=a[k]*a.size();
        for(int i=0;i<a.size();i++){
            if(i<=k){
                answer+=min((int)0,a[i]-a[k]);
            }
            else{
                answer+=min((int)-1,a[i]-a[k]);
            }
        }
        return answer;


}
signed main(){


int n,k;
cin>> n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  cout<<solve(a,k);

}



, In this Programming Language: C++, Now tell me if this Code is compilable or not?