144A - Arrival of the General
2015-05-22 11:57
232 查看
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <queue> #include <algorithm> using namespace std; int a[110]; int main() { int n; int ans = 0; int maxh = 0, minh = 1000000; cin >> n; for(int i = 1; i <= n; ++i) { cin >> a[i]; if(maxh < a[i]) { maxh = a[i]; } if(minh > a[i]) { minh = a[i]; } } int id1 = -1, id2 = -1; for(int i = 1, j = n; i <= n; ++i, --j) { if(a[i] == maxh && id1 == -1) { id1 = i; } if(a[j] == minh && id2 == -1) { id2 = j; } } if(id1 < id2) { ans = id1 - 1 + n - id2; } else { ans = id1 - 1 + n - id2 - 1; } cout << ans << endl; return 0; }
相关文章推荐
- NOJ [1039] Arrival of the General
- codeforces Arrival of the General 题解
- A. Arrival of the General
- Arrival of the General
- codeforces Arrival of the General 题解
- General Overview of The System(一)
- General Introduction of the Spiral Grading Machine
- the thinker of code complete --General Control Issues
- General Knowledge of the Rotary Dryer
- A list of books on general-purpose algorithms for the practical programmer (or 'software engineer')
- Scripts to Check the Setup of the General Ledger Calendar
- 【游学】Fortunately ,photographed with the COO of dolphin browser ,Mr.Wang,and the general mangager of Demo coffee Mr.Yan
- The General Procedure Of Setting Up EDKII Development Environment:搭建EDKII开发环境的通用流程[2.1]
- The General Maintenance Methods of Crusher
- 37 of the General Questions in Interview
- The art in general operation of linux
- General overview of the Linux file system
- The art in general operation of Windows
- General Object Initiating Function by the Example of $injector.instantiate Implementation in angular