Go: /*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1600&lang=jp
	Entrance Examination
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var scanner = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込みintとして返す

func readLine() int {
	if scanner.Scan() {
		number, _ := strconv.Atoi(scanner.Text())
		return number
	}
	return 0
}

func main() {
	// 改行から空白区切りに変更
	scanner.Split(bufio.ScanWords)

	// 0 0 0の行に到達するまでループする
	for {
		// 合格者、不合格者の境目=ギャップ
		m := readLine()   // 受験者の人数
		min := readLine() // 合格者の最小人数
		max := readLine() // 合格者の最大人数

		// 0 0 0の行に到達したのでループを抜け終了する
		if m == 0 && min == 0 && max == 0 {
			break
		}

		// 得点を格納するsliceを初期化
		ps := make([]int, 0, m)

		// sliceに得点を格納する
		for i := 0; i < m; i++ {
			ps = append(ps, readLine())
		}

		tmp := 0    // ギャップを一時的に保存
		gap := 0    // ギャップの最大値を保存
		answer := 0 // ギャップが最大になった時のindex(合格人数)を保存

		// 合格者の最小人数〜最大人数のギャップを計算する
		for i := min; i <= max; i++ {
			tmp = ps[i-1] - ps[i]

			// ギャップの最大値が更新された場合、最大値と合格人数を更新する
			// ギャップが同じ値だった場合も合格人数を更新する
			// (合格人数が多い方が優先されるので後から現れた値が優先される)
			if tmp >= gap {
				gap = tmp
				answer = i
			}
		}
		fmt.Println(answer)
	}
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int main(){
 int p[210];
 int m,nm,nM,sub=0,ans;
 while(1){
  cin >> m >> nm >> nM;
  if(m==0)break;
  sub = 0;
  int i;
  for(i=1;i<=m;i++){
   cin >> p[i];
   if(nm<i && i<=nM+1){
    if(p[i-1]-p[i] > sub){
     sub=p[i-1]-p[i];
     ans=i-1;
    }
   }
  }
  cout << ans << endl;
 }
 return 0;
}

C++: #include <bits/stdc++.h>

int m, min, max;
int P[256];

int main() {
  for(;;) {
    scanf("%d %d %d", &m, &min, &max);
    if( m == 0 and min == 0 and max == 0 ) break;
    for(int i = 1; i <= m; ++i) {
      scanf("%d", &P[i]);
    }
    std::sort(P + 1, P + 1 + m);
    std::reverse(P + 1, P + 1 + m);
    int res = -1, maxdiff = -1;
    for(int i = min; i <= max; ++i) {
      int diff = P[i] - P[i+1];
      if( maxdiff <= diff ) {
        maxdiff = diff;
        res = i;
      }
    }
    printf("%d\n", res);
  }
  
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	while(1){
		int m,nmin,nmax; cin >> m >> nmin >> nmax; if(m==0) return 0;
		int a[205];
		for(int i=1;i<=m;i++) cin >>a[i];
		int X = -1,ans =-1;
		for(int i=nmin;i<=nmax;i++){
			if(X <= a[i]-a[i+1]){
				X=a[i]-a[i+1]; ans=i;
			}
		}
		cout<<ans<<endl;
	}
}

C++: Last login: Mon Dec 26 14:34:37 on console
sira-no-MacBook-Air:~ sira$ ls
Desktop		Downloads	Movies		Pictures
Documents	Library		Music		Public
sira-no-MacBook-Air:~ sira$ cd Desktop/
sira-no-MacBook-Air:Desktop sira$ ls
Programing
sira-no-MacBook-Air:Desktop sira$ cd Programing/
sira-no-MacBook-Air:Programing sira$ ls
A-un_Breathing
Curry_Making
Entrance_Examination
Hanafuda_Shuffle
Koto_Municipal_Subway
Score_Totalizer
Selection_of_Participants_of_an_Experiment
vim.txt
sira-no-MacBook-Air:Programing sira$ cd Entrance_Examination/
sira-no-MacBook-Air:Entrance_Examination sira$ ls
Sample.dat	work		work.cpp
sira-no-MacBook-Air:Entrance_Examination sira$ vim work.cpp



                vector<int> data(m);
                for(i = 0; i < m; i++){
                        cin >> data[i];
                }   

                vector<int> diff(m-1);
                for(i = 0; i < m-1; i++){
                        diff[i] = data[i] - data[i+1];
                }

                for(i = nmin-1; i < nmax; i++){
                        if(diff[i] >= Diff){
                                Diff = diff[i];
                                num = i;
                        }
                }
                cout << num + 1 << endl;
                vector<int>().swap(data);
                vector<int>().swap(diff);
        }
        return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int m,ns,nd,P[201];
  cin >> m >> ns >> nd;
  for(int i=0;i<m;i++){
    cin >> P[i];
  }
  int ans = 0;
  int mmax = -1;
  for(int i=nd;i>=ns;i--){
    int gapp = P[i-1] - P[i];
    if(mmax < gapp){
      mmax = gapp;
      ans = i;
    }
  }
  cout << ans << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	int m,nmi,nma;
	while(cin>>m>>nmi>>nma,m)
	{
		--nmi,--nma;
		int p[m];
		for (int i = 0; i < m; ++i) cin>>p[i];
		int ans=-1,gap=-1;
		for (int i = nmi; i <= nma; ++i)
		{
			if(p[i]-p[i+1]>=gap) ans=i,gap=p[i]-p[i+1];
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n,a,b;
    while(cin >> n >> a >> b){
        if(n == 0 && a == 0 && b == 0)return 0;
        vector<int> vec;
        for(int q = 0;q < n;q++){
            int e;cin >> e;
            vec.push_back(e);
        }
        sort(vec.begin(), vec.end());
        int ma = -1e9;
        int ans = 0;
        for(int i = n-b-1;i < n-a;i++){
            if(vec.at(i+1) - vec.at(i) > ma){
                ma = vec.at(i+1) - vec.at(i);
                ans = n-i-1;
            }
        }
        cout<<ans<<endl;
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

bool solve() {
    int M, Nmin, Nmax;
    cin >> M >> Nmin >> Nmax;
    if (M == 0 && Nmin == 0 && Nmax == 0) {
        return false;
    }
    int p[200];
    for (int j = 0; j < M; j++) {
        cin >> p[j];
    }

    int ind = Nmin-1;
    for (int j = Nmin; j < Nmax; ++j) {
        if (p[j]-p[j+1] >= p[ind]-p[ind+1]) {
            ind = j;
        }
    }
    cout << ind+1 << endl;
    return true;
}

int main() {
    for(;solve(););
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int m, nmin, nmax;
	while (cin >> m >> nmin >> nmax) {
		if (m == 0 && nmin == 0 && nmax == 0) {
			break;
		}
		vector<int> d(m);
		for (int i = 0; i < m; i++) {
			cin >> d[i];
		}
		int MAX = d[nmin-1]-d[nmin];
		int maxn = nmin;
		for (int i = nmin-1; i <= nmax-1; i++) {
			int mm = d[i]-d[i+1];
			if (mm >= MAX) {
				MAX = mm;
				maxn = i+1;
			}
			//cout << MAX << ' ' << maxn << endl;
		}
		cout << maxn << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main(){
  int m,n1,n2,p,res;
  while(cin >> m >> n1 >> n2, m|n1|n2){
    vector<int> a;
    for(int i=0;i<m;i++){
      cin >> p;
      a.push_back(p);
    }
    res = n1;
    for(int i=n1,g=0;i<=(m==n2?n2-1:n2);i++){
      // cout << i << " " << a[i-1]-a[i] << endl;
      if(g<=a[i-1]-a[i]){
	res=i;
	g=a[i-1]-a[i];
      }
    }
    cout << res << endl;
  }
}

C++: #include<iostream>
using namespace std;

int main(){
	while(1){
		int m,n1,n2;//n2は最大人数
		cin>>m>>n1>>n2;

		if(m==0&&n1==0&&n2==0)
			break;
		
		int P[200];
		for(int i=0;i<m;i++){
			cin>>P[i];
		}
		
		int gap=-1;
 		int n=-1;

 		for(int i=n1;i<=n2;i++){
			int g=P[i-1]-P[i];

			if(gap<=g){
				gap=g;
				n=i;
			}
		}

		cout<<n<<endl;
	}
	
	return 0;
}