Problem:
Min Element
数列
a_1,a_2,..,a_N
が与えられます。
この数列の最小値の番号を求めてください。
最小値が複数の場所にあるときは、番号の最も小さいものを答えてください。
入力
N
a_1 a_2...a_N
出力
a_i
が数列の最小値となるような
i
のうち、最も小さいものを出力せよ。
制約
1 \leq N \leq 10^5
1 \leq a_i \leq 10^9
入力例
6
8 6 9 1 2 1
出力例
4

Submitted solutions:

code_snippet: #include<iostream>
using namespace std;

int main()
{
    int N;
    const int MAX_NUM = 100000;
    int input_array[MAX_NUM] = {};
    int min_val = 100000000;
    int min_val_place = 0;
    cin >> N;
    
    for (int i = 1; i<= N;i++)
    {
        cin >> input_array[i - 1];
        if (input_array[i - 1] < min_val)
        {
            min_val = input_array[i - 1];
            min_val_place = i;
        }
    }
    cout << min_val_place << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3736
final_rank: 16

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

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    cout << min_element(a.begin(),a.end())-a.begin()+1 << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3568
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),(k))-v.begin())
#define ub(v,k) (upper_bound(all(v),(k))-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
int main(){
    ll n;cin>>n;
    vp srt;
    rep(i,n){
        ll a;cin>>a;
        srt.pb(a,i);
    }
    sort(all(srt));
    out(srt[0].se+1);
}
accuracy: 1
time_ms: 30
memory_kb: 4840
final_rank: 20

code_snippet: #include<bits//stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    cout<<min_element(a.begin(),a.end())-a.begin() +1<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3096
final_rank: 4

code_snippet: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int mn = 1e9 + 1;
  int ans = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i] < mn) {
      mn = a[i];
      ans = i;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3076
final_rank: 2

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] < a[ans]){
            ans = i;
        }
    }
    cout << ans+1 << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3096
final_rank: 4

code_snippet: #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
 
  int n; cin >> n;
  int e = 1e9 + 1;
  int id = -1;
  for (int i = 1; i <= n; i++) {
    int a; cin >> a;
    if (a < e) {
      e = a;
      id = i;
    }
  }

  cout << id << endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3072
final_rank: 1

code_snippet: #include<iostream>
#include<vector>

using namespace std;

int main() {
	int n; 
	cin >> n;
	vector<int> a(n);
	for (int &x : a) cin >> x;

	int m = 0;
	for (int i = 0; i < n; i++) {
		if (a[m] > a[i]) {
			m = i;
		}
	}

	cout << m + 1 << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3088
final_rank: 3

code_snippet: #include <numeric>
#include <vector>
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <queue>
using namespace std;

int main(const int args, const char* argv[])
{
    int nums;
    cin >> nums;
    auto cmp = [](const long long a, const long long b){
        return a > b;
    };
    priority_queue<long long, vector<long long>, decltype(cmp)> Queue(cmp);
    vector<long long> inputVec;
    
    for(int i = 0; i < nums; i++)
    {
        long long tmp;
        cin >> tmp;
        Queue.push(tmp);
        inputVec.push_back(tmp);
    }
    int tmpI(0);
    while(true)
    {
        if(Queue.top() == inputVec[tmpI])
        {
            cout << tmpI + 1 << endl;
            break;
        }
        tmpI++;
    }
    

    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4744
final_rank: 18

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int m=a[0],p=1;
	for(int i=1;i<n;i++)
	{
		if(m>a[i]){m=a[i];p=i+1;}
	}
	cout<<p<<endl;
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3472
final_rank: 10

code_snippet: #include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<int> values(n); for (auto& v : values) std::cin >> v;
	std::cout << std::distance(values.begin(), std::min_element(values.begin(), values.end())) + 1 << std::endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3116
final_rank: 9

code_snippet: #pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll i,N,x=inf,id=0;
  cin>>N;
  vec v(N);
  rep(i,N){
    cin>>v[i];
    if(chmin(x,v[i]))id=i;
  }
  cout<<id+1<<endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3640
final_rank: 15

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

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A[i] = {a, i};
    }
    int ans = min_element(A.begin(), A.end()) - A.begin() + 1;
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3588
final_rank: 14

code_snippet: //
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int mi = IINF;
    int idx = -1;
    rep(i, n){
        if(mi > a[i]){
            mi = a[i];
            idx = i;
        }
    }
    cout << idx + 1 << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3104
final_rank: 8

code_snippet: #include<iostream>
using namespace std;
int n,A[1<<17];
main()
{
    cin>>n;
    int id=0;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        if(A[id]>A[i])id=i;
    }
    cout<<id+1<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3492
final_rank: 11

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

using namespace std;

#define ll long long

signed main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	cout << (min_element(a.begin(), a.end()) - a.begin() + 1) << endl;
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3100
final_rank: 7

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  cin>>n;
  vector<pll> a(n);
  rep(i,n){
    cin>>a[i].first;
    a[i].second = i+1;
  }
  sort(a.begin(),a.end());

  cout<<(a[0].second)<<endl;

}
accuracy: 1
time_ms: 30
memory_kb: 4336
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }

int main() {

    int n; cin >> n;
    VI a(n); cin >> a;

    int Min = INF, itr = -1;
    FOR(i, 0, n)if (chmin(Min, a[i]))itr = i;
    cout << itr + 1 << "\n";
}
accuracy: 1
time_ms: 20
memory_kb: 3096
final_rank: 4

code_snippet: #include "bits/stdc++.h"
using namespace std;
int main() {
	long N;
	cin >> N;
	vector<pair<long long, long> >A(N);
	long long MIN = 9999999999;
	long ans = 0;
	for (long i = 0; i < N; i++) {
		cin >> A.at(i).first;
		if (MIN > A.at(i).first) {
			MIN = A.at(i).first;
			ans = i + 1;
		}
	}
	cout << ans << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4376
final_rank: 17

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  ll mival=A[0];
  int mit=0;
  for(int i=1;i<N;i++){
    if(mival>A[i]){
      mival=A[i];
      mit=i;
    }
  }

  cout<<mit+1<<endl;

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3544
final_rank: 12