Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- struct dist {
- int val, num;
- void assign(int number, int value) {
- val = value;
- num = number;
- }
- int print1() {
- return val;
- }
- int print2() {
- return num;
- }
- };
- bool operator < (dist a, dist b) {
- return (a.val < b.val);
- }
- const int m = 100001;
- dist b[m];
- int main () {
- int n, v, x1, x2, y1, y2;
- scanf("%d", &n);
- for (int i = 1; i < n + 1; i++) {
- scanf("%d", &v);
- b[i].assign(i, v);
- }
- sort(b+1, b+n+1);
- x1 = b[n-1].print1();
- x2 = b[n].print1();
- y1 = b[n-1].print2();
- y2 = b[n].print2();
- printf ("%d/n %d %d", x2-x1, y2, y1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement