Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a[2]={-1,-1}; for(int i=0;i<n;i++){ int b,c; cin>>b>>c; if(c==a[1]) a[0]=min(a[0],b); if(c>a[1]){ a[0]=b; a[1]=c; } } cout<<a[0]<<" "<<a[1]<<endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
n=int(raw_input()) p=[] w=0 for i in range(n): a,v=map(int,raw_input().split()) p.append((a,v)) w=max(w,v) p.sort() for i in p: if i[1]==w: print i[0],w exit()
PYTHON
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <cstdio> int main(){ int n,a,v,ta = -1,tv = -1; scanf("%d",&n); for(int i = 0; i < n; i++){ scanf("%d%d",&a,&v); if(v > tv || (v == tv && a < ta)){ tv = v; ta = a; } } printf("%d %d\n",ta,tv); return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import static java.util.Arrays.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static void tr(Object... os) { System.err.println(deepToString(os)); } void solve() { int n = sc.nextInt(); int maxV = -1; int maxA = 0; for (int i = 0; i < n; i++) { int a = sc.nextInt(); int v = sc.nextInt(); if (maxV < v) { maxV = v; maxA = a; } else if (maxV == v && maxA > a) { maxA = a; } } out.println(maxA + " " + maxV); } public static void main(String[] args) throws Exception { new Main().run(); } MyScanner sc = null; PrintWriter out = null; public void run() throws Exception { sc = new MyScanner(System.in); out = new PrintWriter(System.out); for (;sc.hasNext();) { solve(); out.flush(); } out.close(); } class MyScanner { String line; BufferedReader reader; StringTokenizer tokenizer; public MyScanner(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public void eat() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { line = reader.readLine(); if (line == null) { tokenizer = null; return; } tokenizer = new StringTokenizer(line); } catch (IOException e) { throw new RuntimeException(e); } } } public String next() { eat(); return tokenizer.nextToken(); } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public boolean hasNext() { eat(); return (tokenizer != null && tokenizer.hasMoreElements()); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main(){ int n; int fish[20] = { 0 }; int ans1 = -1; int ans2; int num; cin >> n; for (int i = 0; i < n; i++){ cin >> num; cin >> fish[num - 1]; } for (int i = 0; i < n; i++){ if (fish[i] > ans1){ ans2 = 0; ans1 = fish[i]; ans2 = i + 1; } } cout << ans2 << " " << ans1 << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
n = int(raw_input()) mxs, minm = 0, 1000 for i in range(n): m, s = map(int, raw_input().split()) if s > mxs: mxs = s minm = m elif s == mxs: if m < minm: minm = m print minm, mxs
PYTHON
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
# coding: utf-8 n = input() A = [] for i in xrange(n): A.append( map(int, raw_input().split()) ) Max = -1 Maxidx = -1 for i in xrange(n): if Max < A[i][1]: Max = A[i][1] Maxidx = i elif Max == A[i][1] and A[Maxidx][0] > A[i][0]: Maxidx = i print A[Maxidx][0], A[Maxidx][1]
PYTHON
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int max = Integer.MIN_VALUE; int e = Integer.MAX_VALUE; for (int i = 1; i <= n; i++) { int c = scanner.nextInt(); int d = scanner.nextInt(); if (max < d) { max = d; e = c; } else if (max == d) { e = Math.min(e, c); } } System.out.println(e + " " + max); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
L = [] for i in range(input()): L.append(map(int, raw_input().split())) print ' '.join(map(str, sorted(L, key=lambda a:(-a[1], a[0]))[0]))
PYTHON
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<set> using namespace std; int main(){ int n; int a, b; int maxv = -1; int id = 21; set<int> I; cin >> n; for ( int i = 0; i < n; i++ ){ cin >> a >> b; I.insert(a); if ( maxv == b ){ if ( id > a ){ maxv = b; id = a; } } else if ( maxv < b ){ maxv = b; id = a; } } cout << id << " " << maxv << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <climits> int main() { int n; int max, argmax; int a, v; std::cin >> n; std::cin >> a >> v; argmax = a; max = v; for (int i=1; i<n; i++) { std::cin >> a >> v; if (v > max) { max = v; argmax = a; } else if ( v == max && a < argmax ) { argmax = a; } } std::cout << argmax << " " << max << std::endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), a, v, max = Integer.MIN_VALUE, maxNum = Integer.MAX_VALUE; for(int i = 0; i < n; i++) { a = sc.nextInt(); v = sc.nextInt(); if(v > max) { max = v; maxNum = a; } if(v == max) maxNum = Math.min(maxNum, a); } System.out.println(maxNum + " " + max); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(), y = sc.nextInt(); for(int i = 0; i < n - 1; i++){ int a = sc.nextInt(); int b = sc.nextInt(); if(y < b){ x = a; y = b; } if(y == b){ if(x > a){ x = a; } } } System.out.println(x + " " + y); sc.close(); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<algorithm> using namespace std; int main(){ int n, a, b; cin >> n; int ra = 1 << 29; int rb = -100; for(int i = 0;i < n;i++){ cin >> a >> b; if(rb < b || rb == b && ra > a){ ra = a; rb = b; } } cout << ra << " " << rb << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<stdio.h> int main(void) { int n,a[21],b[101],i,z,zz,max; max=-1; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d",&a[i],&b[i]); if(b[i]>max){ max=b[i]; z=a[i]; } if(max==b[i]){ if(z<a[i]){ z=z; } else if(z>a[i]){ z=a[i]; } } } printf("%d %d\n",z,max); return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main(void){ int n,a[21],v[21],max=0,num=21; cin>>n; for(int i=0;i<n;++i){ cin>>a[i]>>v[i]; if(v[i]>=max){ if(max!=v[i]) num=a[i]; else if(num>a[i]) num=a[i]; max=v[i]; } } cout<<num<<" "<<max<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<algorithm> using namespace std; int main(){ int n,a[50],v[50]; cin >> n; for(int i=0;i<n;i++)cin >> a[i] >> v[i]; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(v[i] < v[j]){ swap(a[i],a[j]); swap(v[i],v[j]); }else if(v[i] == v[j] && a[i] > a[j]){ swap(a[i],a[j]); swap(v[i],v[j]); } } } cout << a[0] << " " << v[0] << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.io.*; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.List; import java.util.NoSuchElementException; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); PriorityQueue<Data> que = new PriorityQueue<Data>(n,new Comp()); for(int i = 0; i < n; i++) { que.add(new Data(sc.nextInt(),sc.nextInt())); } Data tmp = que.peek(); out.println(tmp.id + " " + tmp.point); out.flush(); } static class Data { int id; int point; Data(int a, int b) { id = a; point = b; } } static class Comp implements Comparator<Data>{ @Override public int compare(Data o1, Data o2) { if(o1.point > o2.point) { return -1; } if(o1.point < o2.point) { return 1; } if(o1.id < o2.id) { return -1; } return 1; } } } //------------------------------// //-----------// class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;} public boolean hasNext() { skipUnprintable(); return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { return (int)nextLong(); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <string> using namespace std; int main() { int n; int p[20]={}; int a,v; int max=0; cin>>n; for(int i=0;i<n;++i){ cin>>a>>v; p[a-1] = v; if(v>max)max=v; } for(int i=0;i<n;++i){ if(p[i]==max){ cout<<i+1<<" "<<p[i]<<endl; break; } } return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<cmath> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) using namespace std; int main(){ int n; cin>>n; int num; int fish; int ansnum; int ansfish=-1; rep(i,n){ cin>>num>>fish; if(ansfish<fish){ ansfish=fish; ansnum=num; }else if(ansfish==fish){ if(ansnum>num){ ansfish=fish; ansnum=num; } } } cout<<ansnum<<" "<<ansfish<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.*; import java.io.*; class Main { public static void main(String[] args) { final Scanner stdin = new Scanner(System.in); final int n = stdin.nextInt(); int maxNum = 0; int maxIndex = Integer.MAX_VALUE; for ( int i = 0; i < n; i++ ){ final int index = stdin.nextInt(); final int num = stdin.nextInt(); if ( num > maxNum || ( num == maxNum && index < maxIndex ) ) { maxNum = num; maxIndex = index; } } System.out.printf( "%d %d\n", maxIndex, maxNum ); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main(){ int a,b,c,max=0,maxh;; cin>>a; for(int i=0;i<a;i++){ cin>>b>>c; if(c>max){ max=c; maxh=b; }else if(max==c&&maxh>b){ max=c; maxh=b; } } cout<<maxh<<" "<<max<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
n = int(input()) x, y = 20, 0 for _ in range(n): a, b = map(int, input().split()) if y < b: x, y = a, b elif y == b and x >= a: x, y = a, b print(x, y)
PYTHON3
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int max = -1; int c = 0; while (n-- > 0) { int m = sc.nextInt(); int w = sc.nextInt(); if (max < w || max == w && c > m) { max = w; c = m; } } System.out.println(c + " " + max); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<algorithm> using namespace std; int main() { int n; int x[20]; int y[20] = {}; cin >> n; for (int i = 0;i < n;i++) { int a, v; cin >> a >> v; x[a - 1] = v; y[a - 1] = x[a - 1]; } sort(y, y + n); for (int i = 0;i < 20;i++) { if (y[n-1] == x[i]) { cout << (i + 1) << ' ' << x[i] << endl; break; } } return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
n = input() a = [map(int, raw_input().split()) for i in range(n)] for i in range(n): (a[i][0], a[i][1]) = (-a[i][1], a[i][0]) a.sort() print a[0][1], -a[0][0]
PYTHON
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main() { int n; cin >> n; int most_fish = -1, most_people = 0; for(int i = 0; i < n; i++) { int a, v; cin >> a >> v; if (most_fish < v) { most_fish = v; most_people = a; } else if (most_fish == v && most_people > a) { most_people = a; } } cout << most_people << " " << most_fish << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int max = 0; int temp[] = new int[21]; for(int i = 0; i < n; i++){ int num = sc.nextInt(); temp[num] = Math.max(sc.nextInt(),temp[num]); max = Math.max(max, temp[num]); } for(int i = 1; i < temp.length; i++){ if(max == temp[i]){ System.out.println(i + " " + temp[i]); break; } } } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
// 2014/05/30 Tazoe #include <iostream> using namespace std; int main() { int n; cin >> n; int a_max = 0; int v_max = -1; for(int i=0; i<n; i++){ int a, v; cin >> a >> v; if(v>v_max || (v==v_max && a<a_max)){ a_max = a; v_max = v; } } cout << a_max << ' ' << v_max << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <algorithm> using namespace std; int main(void){ int n,num,w; pair<int,int> p[20]; cin >> n; for(int i = 0 ; i < n ; i++){ cin >> num >> w; p[i] = make_pair(-w,num); } sort(p,p+n); cout << p[0].second << ' ' << (-1)*p[0].first << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main(){ int n,max=-1,num=-1,a[20],v[20]; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]>>v[i]; if(max<v[i] && max!=v[i]){ num=a[i]; max=v[i]; }else if(max==v[i] && num>a[i]){ num=a[i]; } } cout<<num<<" "<<max<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <algorithm> #define P pair<int,int> using namespace std; bool cmp(const P& p, const P& q){ if(p.first!=q.first) return p.first>q.first; return p.second<q.second; } int main() { int n ; cin >> n ; P a[20]; for(int i=0;i<n;i++) cin >> a[i].second >> a[i].first ; sort(a,a+n,cmp); cout << a[0].second << ' ' << a[0].first << '\n'; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
x=[] for i in range(int(raw_input())): x.append(map(int,raw_input().split())) a,v=sorted(x,key=lambda x:(-x[1],x[0]))[0] print a,v
PYTHON
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { //?????°??????????????? int people = sc.nextInt(); int max = 0; int[] wakasagi = new int[people+1]; Arrays.fill(wakasagi, 0); for(int $ = 1; $ <= people; $++) { wakasagi[sc.nextInt()] = sc.nextInt(); max = Math.max(max, wakasagi[$]); } for(int i = 1;i <= people; i++) { if(wakasagi[i] == max) { System.out.println(i + " " + max); break; } } } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
p = [] n = input() for i in xrange(n): p.append(map(int,raw_input().split())) p.sort(cmp=lambda x,y:x[0]-y[0] if x[1]==y[1] else y[1]-x[1]) print p[0][0],p[0][1]
PYTHON
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <algorithm> #include <vector> using namespace std; struct wakasagi { int a, v; wakasagi(int A, int V) : a(A), v(V) {}; }; bool operator <(wakasagi A, wakasagi B) { if (A.v != B.v) return A.v < B.v; else return A.a > B.a; } int main() { int n, a, v; cin >> n; vector<wakasagi> vec; for (int i = 0; i < n; ++i) { cin >> a >> v; vec.push_back(wakasagi(a, v)); } vector<wakasagi>::iterator top = max_element(vec.begin(), vec.end()); cout << top->a << " " << top->v << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <bits/stdc++.h> using namespace std; int main() { typedef pair<int, int> P; int n; cin >> n; vector<P> av(n); for(P &p : av) cin >> p.second >> p.first, p.first *= -1; sort(av.begin(), av.end()); cout << av[0].second << " " << -av[0].first << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import operator v = {} n = int(input().strip()) for _ in range(n): i,ip = map(int,input().strip().split()) v[i] = ip w = sorted(v.items(),key=operator.itemgetter(1),reverse=True) print("%d %d" % w[0])
PYTHON3
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<stdio.h> int main(void) { int n,a[21],b[101],i,z,zz,max; max=-1; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d",&a[n],&b[n]); if(b[n]>max){ max=b[n]; z=a[n]; } if(max==b[n]){ if(z<a[n]){ z=z; } else if(z>a[n]){ z=a[n]; } } } printf("%d %d\n",z,max); return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main(void){ int n; cin>>n; int a[30]={0}; for(int i=1;i<=n;i++){ int x,y; cin>>x>>y; a[x] = y; } int m =0 ,M = 1; for(int i = 1;i <= n;i++)if(m < a[i])M = i,m = a[i]; cout<<M<<" "<<m<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<algorithm> using namespace std; int a[1000000], b[1000000], maxid, maxn, n; int main() { cin >> n; maxn = 0; maxid = 100000; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; if (maxn < b[i]) { maxn = b[i]; maxid = a[i]; } else if (maxn == b[i]) { maxid = min(maxid, a[i]); } } cout << maxid << ' ' << maxn << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <vector> #include <algorithm> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main() { int n; cin >> n; vector< pair<int,int> > res; rep(i,n) { int a,v; cin >> a >> v; res.push_back(pair<int,int>(v,a)); } sort(res.begin(),res.end(),greater<pair<int,int> >()); int min_num = 21; rep(i,n) { if(res[0].first == res[i].first) { min_num = min(min_num,res[i].second); } } cout << min_num << " " << res[0].first << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; //import java.io.*; //import java.util.Arrays; public class Main { public static void main(String[] args) throws java.io.IOException { Scanner scan = new Scanner(System.in); //InputStreamReader is = new InputStreamReader(System.in); //BufferedReader br = new BufferedReader(is); //String text = scan.next(); int n = scan.nextInt(); int a[] = new int[n]; int v[] = new int[n]; for(int i = 0 ; i < n ; i++){ a[i] = scan.nextInt(); v[i] = scan.nextInt(); } int maxA = a[0]; int maxV = v[0]; for(int i = 1 ; i < n ; i++){ if(maxV < v[i]){ maxA = a[i]; maxV = v[i]; }else if(maxV == v[i]){ if(maxA > a[i]){ maxA = a[i]; } } } System.out.println(maxA + " " + maxV); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
from sys import stdin n = int(input()) book = [0]*(n+1) for _ in stdin.readlines() : if 0 not in book : break a, v = map(int, _.split()) book[a] = v+1 max_val = max(book) print(book.index(max_val), max_val-1)
PYTHON3
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main() { int n; cin >> n; int num = 0; int fish = -1; for (int i = 0; i < n; ++i) { int a, v; cin >> a >> v; if (fish < v) { num = a; fish = v; } else if (fish == v && num > a) { num = a; } } cout << num << ' ' << fish << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main(){ int n[20],num,a[20],z,max=0; cin>>num; for(int i=0;i<num;i++){ cin>>a[i]>>n[i]; if(max<n[i]){ max=n[i]; z=i; }else if(max==n[i]){ if(a[z]>a[i])z=i; } } cout<<a[z]<<" "<<n[z]<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <cstdio> #include <algorithm> using namespace std; int main(){ int n; long a, b; long v[110] = {0}, v2[110] = {0}; scanf("%d", &n); for (int i = 1; i <= n; i++){ scanf("%ld %ld", &a, &b); v[a] += b; v2[a] += b; } sort(v, v + n + 1); reverse(v, v + n + 1); for (int i = 1; i <= n; i++){ if (v2[i] == v[0]){ printf("%ld %ld\n", i, v2[i]); break; } } }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <utility> #include <cstring> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) typedef long long ll; int main() { int n; cin >> n; int fish[n+1]; rep(i,n) { int a, v; cin >> a >> v; fish[a] = v; } int mi = 1; for(int i=2; i<=n; i++) { if(fish[mi] < fish[i]) mi = i; } cout << mi << ' ' << fish[mi] << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <algorithm> #include <vector> using namespace std; struct node { int id; int score; node(int i, int s) : id(i), score(s) { } bool operator <(const node &x) const { if(this->score != x.score) return this->score > x.score; return this->id < x.id; } }; int main() { int n; cin >> n; vector<node> v; while(n--) { int id, score; cin >> id >> score; v.push_back(node(id, score)); } node p = *min_element(v.begin(), v.end()); cout << p.id << ' ' << p.score << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#define _USE_MATH_DEFINES #include <iostream> #include <algorithm> #include <functional> #include <vector> #include <cstdio> #include <cstring> #include <cmath> #include <cfloat> #include <map> #include <queue> #include <stack> #include <list> using namespace std; int main(){ int n; cin>>n; int maxa,maxb; int a,b; cin>>a>>b; maxa=a; maxb=b; for(int i=1;i<n;i++){ cin>>a>>b; if(maxb<b){ maxb=b; maxa=a; } else if(maxb==b){ if(maxa>a) maxa=a; } } cout<<maxa<<" "<<maxb<<endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.*; import java.io.*; import java.awt.geom.*; import java.math.*; public class Main { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static void solve() { int n = in.nextInt(); int ma = -1, max = -1; for (int i=0; i<n; i++) { int a = in.nextInt(); int v = in.nextInt(); if (max < v) { ma = a; max = v; } else if (max == v && a < ma) { ma = a; } } out.println(ma + " " + max); } public static void main(String[] args) { long start = System.currentTimeMillis(); solve(); out.flush(); long end = System.currentTimeMillis(); //trace(end-start + "ms"); in.close(); out.close(); } static void trace(Object... o) { System.out.println(Arrays.deepToString(o));} }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
d={} for _ in[0]*int(input()): a,v=map(int,input().split()) d[v]=d[v]if v in d and a>d[v]else a m=max(d) print(d[m],m)
PYTHON3
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.*; public class Main{ public static void main(String[] args){ new Main().run(); } Scanner sc = new Scanner(System.in); Player[] p; int n; void run(){ while(sc.hasNext()){ n = sc.nextInt(); p = new Player[n]; for(int i=0; i<n; i++) p[i] = new Player(sc.nextInt(), sc.nextInt()); Arrays.sort(p, new Comparator<Player>(){ public int compare(Player p1, Player p2){ int g1 = p1.getGet(); int g2 = p2.getGet(); if(g1 != g2) return g2-g1; int n1 = p1.getNum(); int n2 = p2.getNum(); return n1-n2; } } ); System.out.println(p[0].getNum()+" "+p[0].getGet()); } } class Player{ int num, get; Player(int n, int g){ num = n; get = g; } int getGet(){ return get; } int getNum(){ return num; } } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <queue> #include <map> using namespace std; typedef pair<int, int> P; int n; int fish[1000001]; int main() { cin >> n; priority_queue<P> pq; for(int i = 0; i < n; i++) { int a, v; cin >> a >> v; fish[a] += v; pq.push(P(fish[a], a * (-1))); } P p = pq.top(); cout << p.second * (-1) << " " << p.first << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main(){ int n, A, V; cin >> n; for(int i = 0; i < n; i++){ int a, v; cin >> a >> v; if( i == 0 ){ A = a; V = v; }else{ if( V < v || ( V == v && a < A) ){ V = v; A = a; } } } cout << A << " " << V << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<map> #include<utility> #include<vector> using namespace std; int main() { int n; cin >> n; vector<pair<int ,int> > a(n); for(int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } int max = -1; int min_num = 9999; for(int i = 0; i < n; i++) { if(max < a[i].second) { max = a[i].second; } } for(int i = 0; i < n; i++) { if(max == a[i].second && min_num > a[i].first) { min_num = a[i].first; } } cout << min_num << " " << max << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.*; import java.io.*; public class Main { static void solve (FastScanner in, PrintWriter out, Methods ms) { int n = in.nextInt(); Fisher[] fishers = new Fisher[n]; for (int i=0; i<n; i++) { fishers[i] = new Fisher(in.nextInt(), in.nextInt()); } Arrays.sort(fishers, Comparator.comparing(Fisher::getFishNum).reversed() .thenComparing(Fisher::getId)); out.println(fishers[0].id + " " + fishers[0].fishNum); } public static class Fisher { int id, fishNum; Fisher (int id, int fishNum) { this.id = id; this.fishNum = fishNum; } public int getId () {return id;} public int getFishNum () {return fishNum;} } public static void main (String[] args) { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); Methods ms = new Methods(); solve(in, out, ms); in.close(); out.close(); } static class Methods { public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));} public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];} public int min (int... ar) {Arrays.sort(ar); return ar[0];} public long gcd (long a, long b) {return b>0?gcd(b,a%b):a;} public long lcm (long a, long b) {return a/gcd(a,b)*b;} public long factorial (int i) { if (i==1) return 1; else return i*factorial(i-1); } public int manhat (int x1, int y1, int x2, int y2) { return Math.abs(x1-x2)+Math.abs(y1-y2); } public double euclid (double x1, double y1, double x2, double y2) { return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); } public boolean isPrime (int n) { if (n==2) return true; if (n<2 || n%2==0) return false; for (int i=3; i<=Math.sqrt(n); i+=2) if(n%i==0) return false; return true; } static ArrayList<Character> nextPermutation (ArrayList<Character> list) { int pivotPos = -1; char pivot = 0; for (int i=list.size()-2; i>=0; i--) { if (list.get(i) < list.get(i+1)) { pivotPos = i; pivot = list.get(i); break; } } if (pivotPos==-1 && pivot==0) { list.clear(); return list; } int L = pivotPos+1, R = list.size()-1; int minPos = -1; char min = Character.MAX_VALUE; for (int i=R; i>=L; i--) { if (pivot < list.get(i)) { if (list.get(i) < min) { min = list.get(i); minPos = i; } } } Collections.swap(list, pivotPos, minPos); Collections.sort(list.subList(L, R+1)); return list; } } static class FastScanner { private InputStream in; private byte[] buffer = new byte[1024]; private int length = 0, p = 0; public FastScanner (InputStream stream) { in = stream; } public boolean hasNextByte () { if (p < length) return true; else { p = 0; try {length = in.read(buffer);} catch (Exception e) {e.printStackTrace();} if (length <= 0) return false; } return true; } public int readByte () { if (hasNextByte() == true) return buffer[p++]; return -1; } public boolean isPrintable (int n) {return 33<=n&&n<=126;} public void skip () { while (hasNextByte() && !isPrintable(buffer[p])) p++; } public boolean hasNext () {skip(); return hasNextByte();} public String next () { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int t = readByte(); while (isPrintable(t)) { sb.appendCodePoint(t); t = readByte(); } return sb.toString(); } public String[] nextArray (int n) { String[] ar = new String[n]; for (int i=0; i<n; i++) ar[i] = next(); return ar; } public int nextInt () {return Math.toIntExact(nextLong());} public int[] nextIntArray (int n) { int[] ar = new int[n]; for (int i=0; i<n; i++) ar[i] = nextInt(); return ar; } public long nextLong () { if (!hasNext()) throw new NoSuchElementException(); boolean minus = false; int temp = readByte(); if (temp == '-') { minus = true; temp = readByte(); } if (temp<'0' || '9'<temp) throw new NumberFormatException(); long n = 0; while (isPrintable(temp)) { if ('0'<=temp && temp<='9') { n *= 10; n += temp - '0'; } else throw new NumberFormatException(); temp = readByte(); } return minus? -n : n; } public long[] nextLongArray (int n) { long[] ar = new long[n]; for (int i=0; i<n; i++) ar[i] = nextLong(); return ar; } public double nextDouble () { return Double.parseDouble(next()); } public double[] nextDoubleArray (int n) { double[] ar = new double[n]; for (int i=0; i<n; i++) ar[i] = nextDouble(); return ar; } public void close () { try {in.close();} catch(Exception e){} } } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main(){ int n,a,v; int ansa=1000,ansv=0; cin >> n; for(int i=0;i<n;i++){ cin >> a >> v; if(ansv<v){ ansa = a; ansv = v; } else if(ansv==v&&ansa>a){ ansa = a; ansv = v; } } cout << ansa << ' ' << ansv << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <cstdlib> #include <climits> using namespace std; int main () { int n; cin >> n; int maxv = INT_MIN; int winner = INT_MAX; for( int i = 0; i < n; i++ ) { int a, v; cin >> a >> v; if( maxv < v ) { winner = a; maxv = v; } else if( maxv == v ) { winner = min( a, winner ); } } cout << winner << " " << maxv << endl; return EXIT_SUCCESS; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
// // main.cpp // ggggggggggggggggggggggggggggggggggggg // // Created by h3037175 on 2017/08/01. // Copyright ?? 2017??´ h3037175. All rights reserved. // #include <iostream> using namespace std; int main() { int n,a,v,max=-100000,num; cin>>n; for(int i=0;i<n;i++){ cin>>a>>v; if(max<v || max==v&&num>a){ max=v; num=a; } } cout<<num<<" "<<max<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <queue> #include <algorithm> using namespace std; int main() { using player = pair<int, int>; int n; priority_queue<player> score; cin >> n; for(int i = 0; i < n; i++) { int sc, num; cin >> num >> sc; score.push(make_pair(sc, -num)); } cout << score.top().second * -1 << ' ' << score.top().first << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<vector> #include<string> #include<map> #include<algorithm> using namespace std; int main() { map<int, int>s; int a; cin >> a; for (int b = 0; b < a; b++) { int c, d; cin >> c >> d; if (s[d] > c||s[d]==0)s[d] = c; } auto e = s.end(); e--; cout << e->second << " " << e->first << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<algorithm> using namespace std; int main(){ int n; int a,b; int z[1000][1000] = {0}; cin >> n; for(int i=0;i<n;i++){ cin >> a >> b; z[b][a] = 1; } for(int i=100;i>=0;i--){ for(int j=1;j<=20;j++){ if(z[i][j] == 1){ cout << j << " " << i << endl; return 0; } } } }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <stdio.h> int main(){ int n,l,r,a[100],top=1; scanf("%d",&n); for(int i=1;i<=n;i++)a[i]=0; for(int i=1;i<=n;i++){ scanf("%d%d",&l,&r); a[l]+=r; } for(int i=1;i<=n;i++)if(a[i]>a[top])top=i; printf("%d %d\n",top,a[top]); }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.*; class Main { public static void main (String[] args) { Scanner scanner = new Scanner(System.in); String out = ""; int n = scanner.nextInt(); scanner.nextLine(); List<String> a = new ArrayList<String>(); for (int ii = 0; ii < n; ii++) { String line = scanner.nextLine(); String[] works = line.split(" "); works[0] = "00" + works[0]; works[0] = works[0].substring(works[0].length() - 2); works[1] = "000" + works[1]; works[1] = works[1].substring(works[1].length() - 3); a.add(works[1] + " " + works[0]); Collections.sort(a); Collections.reverse(a); } List<String>aa = new ArrayList<String>(); String[] tops = a.get(0).split(" "); for (String el : a) { String[] works = el.split(" "); if (!works[0].equals(tops[0])) { break; } aa.add(works[1] + " " + works[0]); } Collections.sort(aa); System.out.println(Integer.parseInt(aa.get(0).split(" ")[0]) + " " + Integer.parseInt(aa.get(0).split(" ")[1])); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<stdio.h> int main(void) { int n,a,b,i,m,z; m=-1; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d",&a,&b); if(m<b){ m=b; z=a; } else if(m==b){ if(a<z){ z=a; } } } printf("%d %d\n",z,m); return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<string> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main(void){ int n; cin>>n; int a[30]={0}; for(int i=1;i<=n;i++){ int x,y; cin>>x>>y; a[x] = y; } int m=0,M=1; for(int i=1;i<=n;i++){ if(m < a[i]){ M = i; m = a[i]; } } cout<<M<<" "<<m<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <algorithm> #include <cstdlib> #include <cstring> #include <vector> #include <cstdio> using namespace std; int main() { int n; cin>>n; int id,val=-1; for(int i=0;i<n;i++) { int a,v; cin>>a>>v; if(val<v) { id=a; val=v; } else if(val==v) { id=min(id,a); } } cout<<id<<" "<<val<<endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main() { int n,a,v,maxa=-1,maxv=-1; cin>>n; for(int i=0;i<n;i++){ cin>>a>>v; if(maxv<v){ maxa=a; maxv=v; } else if(maxv==v && a<maxa){ maxa=a; maxv=v; } } cout<<maxa<<" "<<maxv<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main() { int n, index, w, idx = 0, mx = -1; cin >> n; for(int i=0;i < n; ++i) { cin >> index >> w; if (mx < w || (mx == w && idx > index)) idx = index-1, mx = w; } cout << idx+1 << " " << mx << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <utility> using namespace std; int main() { pair<int, int> perf[20], max; int i, n; cin >> n; for (i = 0; i < n; i++) { cin >> perf[i].first >> perf[i].second; } max = perf[0]; for (i = 1; i < n; i++) { if ((max.second < perf[i].second) || (max.second == perf[i].second && max.first > perf[i].first)) { max = perf[i]; } } cout << max.first << " " << max.second << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Entrant { int num; int wakasagi; bool operator<(const Entrant& right) const { return wakasagi == right.wakasagi ? num > right.num : wakasagi < right.wakasagi; } }; int main(void) { int n; cin >> n; vector<Entrant> entrants(n); for (auto& e : entrants) { cin >> e.num >> e.wakasagi; } sort(entrants.begin(), entrants.end()); cout << entrants.back().num << " " << entrants.back().wakasagi << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; int[] v=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); v[i]=sc.nextInt(); } for(int i=0;i<n-1;i++){ for(int j=n-1;j>i;j--){ if(a[j-1]>a[j]){ int box=v[j-1]; v[j-1]=v[j]; v[j]=box; box=a[j]; a[j]=a[j-1]; a[j-1]=box; } } } for(int i=0;i<n-1;i++){ for(int j=n-1;j>i;j--){ if(v[j-1]<v[j]){ int box=v[j-1]; v[j-1]=v[j]; v[j]=box; box=a[j]; a[j]=a[j-1]; a[j-1]=box; } } } System.out.println(a[0]+" "+v[0]); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<algorithm> #include<utility> using namespace std; int main(){ int n; int i,num,w; pair<int,int> fish[100] ; cin >> n; for(i=0;i<n;i++){ cin >> num >> w; fish[i] = make_pair(-w,num); } sort(fish,fish+n); cout << fish[0].second << " " << (-1)*fish[0].first << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int n, a, v; cin >> n; vector<int> c(n, 0); for(int i = 0; i < n; i++) { cin >> a >> v; c[a - 1] += v; } int ptr = -1, cnt = -1; for(int i = 0; i < n; i++) { if(cnt < c[i]) { ptr = i; cnt = c[i]; } } cout << ptr + 1 << ' ' << cnt << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<cstdio> #include<iostream> #include<utility> using namespace std; int main(void){ int n; pair<int,int> inp; pair<int,int> max; cin>>n; cin>>max.first>>max.second; for(int i=1;i<n;i++){ cin>>inp.first>>inp.second; if(inp.second>max.second||(inp.second==max.second&&inp.first<max.first)) max=inp; } cout<<max.first<<" "<<max.second<<endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<bits/stdc++.h> using namespace std; int n,a,v,cnt[21],maxcnt; int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>a>>v; cnt[a-1]+=v; maxcnt=max(maxcnt,cnt[a-1]); } for(int i=0;i<n;i++){ if(maxcnt==cnt[i]){ cout<<i+1<<' '<<maxcnt<<endl; break; } } return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<map> using namespace std; struct data{ int n,m; data(int a,int b){ n=a;m=b; } data(){} bool operator<(const data &d)const{ if(m!=d.m)return (m<d.m); else return (n>d.n); } }; int main(){ int n; cin>>n; data Max(100000,0); for(int i=0;i<n;i++){ int p,q; cin>>p>>q; Max=max(Max,data(p,q)); } cout<<Max.n<<" "<<Max.m<<endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; int[] v=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); v[i]=sc.nextInt(); } for(int i=0;i<n-1;i++){ for(int j=n-1;j>i;j--){ if(a[j-1]>a[j]){ int box=v[j-1]; v[j-1]=v[j]; v[j]=box; box=a[j]; a[j]=a[j-1]; a[j-1]=box; } } } int max=-1; int maxPtr=0; for(int i=0;i<n;i++){ if(v[i]>max){ max=v[i]; maxPtr=a[i]; } } System.out.println(maxPtr+" "+max); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Arrays; import java.util.Scanner; public class Main { static class Player implements Comparable<Player>{ int number; int fish; Player(int number, int fish) { this.number = number; this.fish = fish; } public int compareTo(Player o) { return this.fish == o.fish ? this.number - o.number : o.fish - this.fish; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); Player p[]; int n; n = sc.nextInt(); p = new Player[n]; for (int i = 0; i < n; i++) { p[i] = new Player(sc.nextInt(), sc.nextInt()); } Arrays.sort(p); System.out.println(p[0].number + " " + p[0].fish); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main() { int number,score,n; int winnerNumber,winnerScore = -1; cin >> n; for(int i=0; i<n; i++){ cin >> number >> score; if(score > winnerScore ){ winnerScore = score; winnerNumber = number; continue; } if(score == winnerScore && number < winnerNumber){ winnerScore = score; winnerNumber = number; } } cout << winnerNumber << ' ' << winnerScore << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main(void){ int n,num,w,takata,vic = 0; int p[20] = {0}; cin >> n; for(int i = 0 ; i < n ; i++){ cin >> num >> w; p[num-1] = w; } takata = p[0]; for(int i = 1 ; i < n ; i++){ if(takata < p[i]){ takata = p[i]; vic = i; } } vic++; cout << vic << ' ' << takata << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main(){ int n, a, v, m_a, m_v; cin >> n; m_v = 0; for(int i=0; i<n; i++){ cin >> a >> v; if(v >= m_v){ if(v != m_v || v == m_v && a < m_a){ m_a = a; m_v = v; } } } cout << m_a << " " << m_v << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main() { int n; int a, b; int maxv = -1; int id = 21; cin >> n; for(int i = 0; i < n; i++) { cin >> a >> b; if ( maxv == b ) { if( id > a ) { maxv = b; id = a; } } else if ( maxv < b ) { maxv = b; id = a; } } cout << id << " " << maxv << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <cstdio> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n; scanf("%d",&n); int a0,v0=-1; rep(i,n){ int a,v; scanf("%d%d",&a,&v); if(v0<v || v0==v && a0>a) a0=a, v0=v; } printf("%d %d\n",a0,v0); return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; //Surf Smelt Fishing Contest public class Main{ void run(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ra = 101, rb = -1; while(n--!=0){ int a = sc.nextInt(), b = sc.nextInt(); if(rb < b || rb==b && a < ra){ ra = a; rb = b; } } System.out.println(ra+" "+rb); } public static void main(String[] args) { new Main().run(); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); int[] a = new int[n]; int[] v = new int[n]; int[] w = new int[n]; for(int i=0;i<n;i++){ a[i] = sc.nextInt(); v[i] = sc.nextInt(); } w = Arrays.copyOf(v, n); Arrays.sort(w); int min = Integer.MAX_VALUE; for(int i=0;i<n;i++){ if(v[i]==w[n-1]){ min = Math.min(min, a[i]); } } System.out.println(min + " " + w[n-1]); } } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int max_idx = -1; int max = -1; for(int i=0;i<n;i++){ int a = stdIn.nextInt(); int b = stdIn.nextInt(); if(max<b){ max_idx = a; max = b; } else if(max==b&&max_idx>a){ max_idx = a; } } System.out.println(max_idx+" "+max); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
N=int(input()) number={} for i in range(N): a,b=map(int,input().split()) number[a] = b number_max = max(number.values()) answer = [] for v,m in number.items(): if m==number_max: answer.append(v) print(min(answer),number_max)
PYTHON3
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main(){ int n; int a,b; cin >> n ; cin >> a >> b ; int max=b,num=a; for( int i=1 ; i<n ; i++ ){ cin >> a >> b ; if( max < b ){ max=b; num=a; } else if( max == b && num > a ) num=a; } cout << num << " " << max << endl ; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; #define N 20 int main(void) { int n; int p[N + 1]; //添え字が参加者番号、値は釣った匹数 int a, v; int ans; cin >> n; for(int i = 0; i < n; ++i) { cin >> a >> v; p[a] = v; } ans = 1; for(int i = 1; i <= n; ++i) { if(p[ans] < p[i]) ans = i; } cout << ans << ' ' << p[ans] << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <algorithm> #include <string> #include <vector> #include <map> #include <iomanip> #include <iostream> using namespace std; /** Problem0095 : Surf Fishing Contest **/ int main() { map<int, vector<int> > list; int n, a, v, maxV=0; cin >> n; for (int i=0; i<n; i++) { cin >> a >> v; list[v].push_back(a); maxV = max(v, maxV); } vector<int> vec = list[maxV]; sort(vec.begin(), vec.end()); cout << vec[0] << " " << maxV << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
import java.util.Arrays; import java.util.Scanner; public class Main { public static class Fisher implements Comparable<Fisher>{ int number, fished; public Fisher(int number, int fished) { super(); this.number = number; this.fished = fished; } @Override public int compareTo(Fisher arg0) { return arg0.fished - this.fished == 0 ? this.number - arg0.number : arg0.fished - this.fished; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); Fisher[] fish = new Fisher[n]; for(int i = 0; i < n; i++){ final int a = sc.nextInt(); final int v = sc.nextInt(); fish[i] = new Fisher(a, v); } Arrays.sort(fish); System.out.println(fish[0].number + " " + fish[0].fished); } }
JAVA
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> using namespace std; int main() { int n, a, v, ma, mv = -1; cin >> n; for(int i = 0; i < n; i++) { cin >> a >> v; if(v > mv) { ma = a; mv = v; } else if(v == mv && ma > a) { ma = a; } } cout << ma << ' ' << mv << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; int main(void) { int n, max_player,a,b,max=-1; cin >> n; while (n) { cin >> a >> b; if (b > max) { max_player = a; max = b; } else if (b == max) { if (max_player > a)max_player = a; } n--; } cout << max_player << " " << max << endl; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <stdio.h> using namespace std; int main() { int n,a,v,ma=999,mv=-1; cin >> n; for (n;n>0;n--) { cin >> a >> v; if (mv<=v) { if (mv==v) ma=min(ma,a); else ma=a; mv=v; } } cout << ma << ' ' << mv << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
n = int(input()) ans=[-1]*21 for _ in range(n): a, b = map(int, input().split()) ans[a] = b print(ans.index(max(ans)), max(ans))
PYTHON3
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include<iostream> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) int main() { int n; cin >> n; int ra = 1000, rb = -1; rep (i, n) { int a, b; cin >> a >> b; if (rb < b || (rb == b && ra > a)) { ra = a; rb = b; } } cout << ra << " " << rb << endl; return 0; }
CPP
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
n = int(input()) alist = [] vlist = [] for _ in range(n): a, v = map(int, input().split()) alist.append(a) vlist.append(v) max = 0 num = 10**9 for a, v in zip(alist, vlist): if v > max: num = a max = v elif v == max: if a < num: num = a print(num, max)
PYTHON3
p00095 Surf Smelt Fishing Contest
A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish caught. If there are multiple winners, output the one with the lowest participant number. input The input is given in the following format. n a1 v1 a2 v2 :: an vn n (1 ≤ n ≤ 20) represents the number of participants and ai represents the participant number. Participant numbers are different integers between 1 and n. vi (0 ≤ vi ≤ 100) is the number of animals acquired by the participant ai. output Output the winner's participant number and the number of fish caught on one line separated by blanks. Example Input 6 1 14 2 25 3 42 4 11 5 40 6 37 Output 3 42
7
0
#include <iostream> #include <algorithm> #include <vector> using namespace std; typedef pair<int, int> P; bool compare(P v1, P v2){ if(v1.second > v2.second) return true; else if(v1.second < v2.second) return false; else{ if(v1.first < v2.first) return true; else return false; } } int main(){ vector<P> v; int n; cin >> n; P t; for(int i = 0 ; i < n ; i++){ cin >> t.first >> t.second; v.push_back(t); } sort(v.begin(), v.end(), compare); cout << v[0].first << ' ' << v[0].second << endl; return 0; }
CPP