prompt
string
response
string
Problem: 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 l...
#include<iostream> #include<stdio.h> using namespace std; int main(){ int a[30]={0},p,q,m=0,b=1; int n; cin>>n; for(int i=0;i<n;i++){ cin>>p>>q; a[p]+=q; } for(int i=0;i<30;i++){ if(m<a[i]){ m=a[i]; b=i; } } cout<<b<<" "<<m<<endl; ...
Problem: 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 l...
n = int(input()) a = [0 for i in range(n)] v = [0 for i in range(n)] for i in range(n): a[i], v[i] = [int(i) for i in input().split()] v1 = sorted(v) max_ = v1[-1] indexes = [i for i, x in enumerate(v) if x == max_] a_ = min([a[i] for i in indexes]) print(a_,max_)
Problem: 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 l...
#include<iostream> #include<map> #include<vector> #include<algorithm> using namespace std; typedef pair<int,pair<int,int> > P; int main(void){ pair<int,pair<int,int> > p; vector<P> v; int n,a,b; cin >> n; for(int i = 0;i < n; i++){ cin >> p.second.second >> p.first; p.second.first = 100 - p.second.sec...
Problem: 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 l...
#include <iostream> using namespace std; int main(){ int n; cin >> n; int max=-1; int kouho =0; for(int i=0;i<n;i++){ int a,b; cin >> a >> b; if(max == b && kouho > a){ kouho = a; } if(max < b){ max = b; kouho = a; } ...
Problem: 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 l...
#include<bits/stdc++.h> using namespace std; int main() { int n,men,fish,num,fishmax; cin>>n; for(int i=0;i<n;i++){ cin>>men>>fish; if(i==0){ num=men; fishmax=fish; } else { if(fish>fishmax){ fishmax=fish; num=men; } else if(num...
Problem: 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 l...
#include<iostream> #include<vector> #include<algorithm> using namespace std; typedef pair<int,int> P; int main(){ int n; cin>>n; vector<P> data; for(int i=0; i<n; i++) { int a, v; cin>>a>>v; data.push_back(P(-v,a)); } sort(data.begin(),data.end()); cout<<data[0].sec...
Problem: 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 l...
n = int(input()) ma = 20 mv = 0 while n > 0: a,v = map(int,input().split()) if mv < v: ma,mv = a,v elif mv == v and ma >= a: ma,mv = a,v n -= 1 print(ma,mv)
Problem: 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 l...
#include<iostream> using namespace std; int main(){ int n,x,y=-1; cin>>n; while(n--){ int a,b; cin>>a>>b; if(y<b || b==y&&a<x)x=a,y=b; } cout<<x<<' '<<y<<endl; return 0; }
Problem: 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 l...
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static int[][] fishingData; static int n; public static void main(String[] args) { while(read()){ solve(); } } static boolean read(){ if( !sc.hasNext() )return false; n = sc.nextInt(); fishingData = new int[n][2]; ...
Problem: 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 l...
#include <iostream> using namespace std; int main() { int n; while( cin >> n ){ int ansA, ansV; ansA = 100, ansV = 0; for( int i = 0; i < n; ++i ){ int a, v; cin >> a >> v; if( ansV < v ){ ansA = a; ansV = v; }else if( ansV == v && ansA > a ){ ansA = a; } } cout << ansA << " " <<...
Problem: 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 l...
#include<iostream> #include<cstring> #include<algorithm> #include<string> #include<vector> #include<cstdio> #include<cmath> #define pb(in,tmp) in.push_back(tmp) #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,b) loop(i,0,b) #define all(in) in.begin(),in.end() using namespace std; int main(){ int n; cin>>n; vecto...
Problem: 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 l...
#include<iostream> #include<algorithm> #include<vector> using namespace std; typedef pair<int,int> P; bool cmp(const P& a,const P& b) { if(a.first == b.first) return a.second < b.second; return a.first > b.first; } int main() { int n; vector<P> vec; cin >> n; for(int i=0;i<n;i++) { int a,v;...
Problem: 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 l...
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; int v; int maxPtr=0; int max=Integer.MIN_VALUE; for(int i=0;i<n;i++){ a=sc.nextInt(); v=sc.nextInt(); if(v>max){ max=v; maxPtr=a; }else i...
Problem: 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 l...
#include <iostream> #include <string> #include <vector> #include <map> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<pair<int,int>> list; for (int i=0; i<n; ++i) { int a, v; cin >> a >> v; list.push_back(make_pair(-v, a)); } sort(list.beg...
Problem: 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 l...
#include <iostream> #include <algorithm> using namespace std; int main() { int n; pair<int,int> ans(1,0); cin >> n; while(n--) { int a, v; cin >> a >> v; ans = min(ans, make_pair(-v, a)); } cout << ans.second << " " << -ans.first << endl; return 0; }
Problem: 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 l...
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<pair<int,int> >vec; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; vec.push_back(pair<int,int>(-b,a)); } sort(vec.begin(),vec.end()); cout<<vec[0].second<<" "<<-vec[0].first<<endl; retu...
Problem: 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 l...
from operator import itemgetter n = int(input()) rs = [list(map(int,input().split())) for i in range(n)] rs = sorted(rs,key=itemgetter(0)) print(' '.join(map(str, sorted(rs, key=itemgetter(1),reverse=True)[0])))
Problem: 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 l...
n=input() a0,v0=n,0 for i in range(n): a,v=map(int,raw_input().split()) if v>v0: a0,v0=a,v elif v==v0: a0=min(a0,a) print a0,v0
Problem: 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 l...
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main() { int n,a[20],v[100],deta; cin>>n; for(int i=0;i<n;i++)cin>>a[i]>>v[i]; for(int i=0;i<n-1;i++)for(int j=0;j<n-1;j++) { if(v[j]<v[j+1]||(v[j]==v[j+1]&&a[j]>a[j+1])) { ...
Problem: 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 l...
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<n;i++) using namespace std; typedef pair<int, int>P; map<int, int>mp; int main() { int n; cin >> n; rep(i, n) { int a, v; cin >> a >> v; mp[a] += v; } vector<P>V; for (P i : mp)V.push_back(i); stable_sort(V.begin(), V.end(), [](P a, P b) {return a.second ...
Problem: 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 l...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector< pair< long long int, long long int > > cnt; long long int n; cin >> n; for ( long long int i = 0; i < n; i++ ) { long long int in0, in1; cin >> in0 >> in1; cnt.push_back( make_pair( -in1, in0 ) ...
Problem: 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 l...
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef pair<int, int> p; void solve() { int n; cin >> n; vector<p> list(n); for(int i = 0; i < n; ++i) { cin >> list[i].second >> list[i].first; } sort(list.begin(), list.end()); int max_point = list[n - 1].first; int min_num ...
Problem: 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 l...
#include <iostream> #include <algorithm> using namespace std; int main(){ for(int n;cin>>n;){ pair<int,int> p[20]; for(int i=0;i<n;i++) cin>>p[i].second>>p[i].first,p[i].first*=-1; sort(p,p+n); cout<<p[0].second<<' '<<p[0].first*-1<<endl; } return 0; }
Problem: 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 l...
a=[] for i in range(int(input())): a.append(list(map(int,input().split(" ")))) a.sort(reverse=True) a.sort(key=lambda x:x[1]) print(*a[-1])
Problem: 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 l...
#include<cstdio> using namespace std; int min(int a,int b){return(a < b)?a:b;} int main(){ int n; scanf("%d",&n); int num = 99999,fish = 0; for(int i = 0; i < n; i++){ int x,y; scanf("%d%d",&x,&y); if(fish <= y){ if(fish == y)num = min(num,x); else num = x; fish = y; } } printf("%d %d\n",num,fish...
Problem: 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 l...
#include <iostream> using namespace std; int info[22]; int main() { int n, a, v; int max_idx = 0; cin >> n; info[max_idx] = -10; for (int i = 0; i < n; i++) { cin >> a >> v; info[a] = v; } for (int i = 1; i <= n; i++) if (info[max_idx] < info[i]) ...
Problem: 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 l...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(void){ // Your code here! ll n; cin>>n; ll a[n],b[n]; vector<pair<ll, ll> > ab(n); for(ll i=0;i<n;i++)cin>>a[i]>>b[i]; for(int i=0;i<n;i++){ ab[i] = make_pair(b[i],a[i]); } sort(ab.begin(),ab.end()); int mi=101; for(int i=0;...
Problem: 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 l...
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--){ i...
Problem: 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 l...
n = int(input()) av = [None] * n for i in range(n): a, v = map(int, input().split()) av[i] = [a, v] av.sort() ans = av[0][0] for a, v in av: if av[ans - 1][1] < v: ans = a print(ans, av[ans - 1][1])
Problem: 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 l...
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; int main(){ int n; cin>>n; P a[101]; for(int i=0;i<n;i++) cin>>a[i].second>>a[i].first,a[i].second*=-1; sort(a,a+n,greater<P>()); cout << -a[0].second<<" "<<a[0].first<<endl; return 0; }
Problem: 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 l...
n = int(raw_input()) lis = [] num = {} for i in xrange(n): a,b = map(int,raw_input().split()) num[a] = b lis.append(b) lis.sort(reverse = True) list = [] for var in num: if lis[0] == num[var]: list.append(var) list.sort() print list[0],lis[0]
Problem: 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 l...
#include<iostream> using namespace std; int main(){ int n,m=1;cin >> n; int d[21]={}; int a,v; while(n--){ cin >> a >> v;d[a]=v; if(d[m]==d[a]&&a<m)m=a; if(d[m]<d[a])m=a; } cout << m << " " << d[m] << endl; }
Problem: 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 l...
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int max = -1; int ind = -1; for(int i = 0; i < n; ++i){ int d = sc.nextInt(); int c = sc.nextInt(); if( c > max ){ max = c; ind = d; }else if( c ...
Problem: 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 l...
#include<vector> #include<iostream> #include<algorithm> using namespace std; int main(){ int N,x,y,ans1,ans2=-1; vector <int> num; cin >> N; while(N--){ cin >> x >> y; if(y>ans2){ num.clear(); num.push_back(x); ans2 = y; } else if(y==ans2){ num.push_back(x); } } sort(num.begin(),num.end()); ...
Problem: 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 l...
#include<bits/stdc++.h> using namespace std; #define rep(i,a) for(int i = 0; i < (a); i++) #define reps(i, a, b) for(int i = (a); i < (b); i++) #define INF 1e9 typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int, int> pii; int main() { int n; vector<pii> v; cin >> n; rep(i, n) { int ind, a; cin >> ...
Problem: 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 l...
#include <bits/stdc++.h> using namespace std; int main(void){ int n,winner,max=0,a,v; cin>>n; for (int i=0;i<n;i++) { cin>>a>>v; if (v>max) { winner=a; max=v; } else if (v==max) { if (a<winner) { winner=a; } } ...
Problem: 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 l...
import java.util.Scanner; public class Main{ public static void main(String args[]){ new Main().mainrun(); } private Scanner scan; private int n,id,value; private void mainrun() { scan = new Scanner(System.in); n = scan.nextInt(); id = -1; value = Integer.MIN_VALUE; for(int i = 0;i < n;i++) { ...
Problem: 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 l...
#include<iostream> #include<string> #include<vector> #include<cstdio> #include<sstream> #include<algorithm> #include<cmath> #include<map> #include<functional> using namespace std; int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;} string itos(int x){stringstream ss;ss<<x;return ss.str();} int main(){...
Problem: 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 l...
#include <iostream> using namespace std; int main(){ int n; while(cin >> n){ int minA, maxV = -1; for(int i = 0; i < n; i++){ int a, v; cin >> a >> v; if(maxV < v || maxV == v && minA > a){ minA = a; maxV = v; } } cout << minA << " " << maxV << endl; } ...
Problem: 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 l...
N = int(input()) n, a = -1, 0 for x in sorted([list(map(int, reversed(input().split()))) for i in range(N)], reverse=True): if x[0] < n: break n, a = x print(a, n)
Problem: 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 l...
#include <iostream> #include <algorithm> #include <vector> #include <cstdio> using namespace std; int main(void) { int n; int a, v; vector < pair <int, int> > vi; cin >> n; while (n--){ cin >> a >> v; vi.push_back(make_pair(v, a)); } sort(vi.rbegin(), vi.rend()); int ret[2] = {0}, ma = vi[0].first; for...
Problem: 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 l...
n = int(input()) d = {t[0]: t[1] for t in [list(map(int, input().split())) for _ in range(n)]} print(*max(d.items(), key=lambda x: x[1]))
Problem: 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 l...
#include <stdio.h> #include <cmath> #include <algorithm> using namespace std; int main(){ int n,tmp_id,max_id,max=-1,tmp; scanf("%d",&n); for(int i=0; i < n; i++){ scanf("%d %d",&tmp_id,&tmp); if(tmp > max){ max = tmp; max_id = tmp_id; }else if(tmp == max){ if(max_id > tmp_id){ max_id = tmp_...
Problem: 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 l...
a = [0] * 20 v = [0] * 20 a_v = [] for i in range(int(raw_input())): a[i],v[i] = map(int, raw_input().split()) a_v.append([a[i], v[i]]) a_v.sort() ans2 = max(v) for i in a_v: if i[1] == ans2: ans1 = i[0] break print "{} {}".format(ans1, ans2)
Problem: 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 l...
lis = [] for i in xrange(input()): lis.append(map(int,raw_input().split())) print " ".join(map(str,sorted(lis,cmp=lambda a,b:cmp(a[0],b[0]) if a[1] == b[1] else cmp(b[1],a[1]))[0]))
Problem: 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 l...
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<cmath> using namespace std; int a,b,ma,ans,n; int main(){ cin>>n; cin>>a>>b; ma=b,ans=a; for(int i=1;i<n;i++){ cin>>a>>b; if(ma<b){ ans=a; ma=b; }else if(ma==b&&ans>a)ans=a; ...
Problem: 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 l...
#include <algorithm> #include <iomanip> #include <iostream> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; #define reps(i,f,n) for(int i=f; i<int(n); ++i) #define rep(i,n) reps(i,0,n) int main() { int n; cin >> n; ...
Problem: 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 l...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; vector<pii> v; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a, b; scanf("%d %d", &a, &b); v.push_back(pii(-b, a)); } sort(v.begin(), v.end()); cout << v[0].second << " "...
Problem: 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 l...
import java.util.Scanner; class Main { Scanner scan = new Scanner(System.in); public static void main(String args[]){ Main app = new Main(); while(app.scan.hasNext()){ int n = Integer.parseInt(app.scan.nextLine()); int[][] entrant = new int[n][2]; app.input(n, entrant); int index = app.max(n,entrant);...
Problem: 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 l...
#include "bits/stdc++.h" using namespace std; typedef long long ll; int main(){ int n; cin >> n; int A = 0, V = -1; for(int i = 0; i < n; i++){ int a, v; cin >> a >> v; if(v > V){ A = a; V = v; } if(v == V && a < A){ A = a; ...
Problem: 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 l...
print(*sorted([list(map(int, input().split())) for _ in [0]*int(input())], key=lambda x:(-x[1],x[0]))[0])
Problem: 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 l...
#include <algorithm> #include <iostream> #include <utility> #include <vector> using namespace std; int main(){ int n; cin >> n; vector<pair<int,int> > p(n, pair<int,int>(0,0)); for (int i = 0; i < n; i++){ cin >> p[i].second >> p[i].first; p[i].second = -p[i].second; } sort(p.begin(), p.end(), grea...
Problem: 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 l...
#include<iostream> #include<algorithm> #include<cstdio> using namespace std; int main(){ int n; int ma,mv; int a,v; scanf("%d",&n); mv=0; ma=1; for(int i=0;i<n;i++){ scanf("%d %d",&a,&v); if(v>mv){ ma=a; mv=v; } else if(v==mv && a<ma){ ma=a; mv=v; } } pr...
Problem: 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 l...
#include<bits/stdc++.h> using namespace std; int main(){ pair<int,int> p[100]; int n; cin>>n; for(int i=0;i<n;i++)cin>>p[i].second>>p[i].first,p[i].first*=-1; sort(p,p+n); cout<<p[0].second<<" "<<-p[0].first<<endl; return 0; }
Problem: 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 l...
#include<bits/stdc++.h> using namespace std; #define all(vec) vec.begin(),vec.end() typedef long long int ll; typedef pair<int,int> P; const ll MOD=1000000007; const ll INF=1000000010; const ll LINF=4000000000000000010LL; const int MAX=310; const double EPS=1e-9; int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; int main(){ ...
Problem: 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 l...
a={} for i in range(int(input())): b,c=map(int,input().split()) a[b]=c print(*max(a.items(),key=lambda x:x[1]))
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<iostream> #include<algorithm> #include<functional> using namespace std; int main(){ int n,m; while(cin>>n>>m,n!=0||m!=0){ int a[1000]={0},ans=0; for(int i=0;i<n;i++)cin>>a[i]; sort(a,a+n,greater<int>()); if(n>=m){ for(int i=0;i<n;i++){ if((i+1)%m==0){ a[i]=0; } } } for(int i=0;i<n...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ int n,m; vector<int> v; int ans; while(1){ cin >> n >> m; if(!n && !m)break; ans = 0; v.resize(n); for(int i=0;i<n;i++){ cin >> v[i]; ans += v[i]; } sort(v.begin(),v.end()); f...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
while True: try: n, m = (int(x.strip()) for x in raw_input().split()) if n == 0 and m == 0: break p = [int(x.strip()) for x in raw_input().split()] s = sum(p) p.sort(reverse=True) for x in p[m - 1::m]: s -= x print s except: pass
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,m; while(cin>>n>>m&&!(n==0&&m==0)){ int num=n/m; vector<int> v; for(int i = 0; i < n; i++){ int t; cin>>t; v.push_back(t); } sort(v.begin(),v.end(),greater<int>()); int sum=0; for(int i = 0; i ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int m,n; static int[] p; public static void main(String[] args) { while(read()) solve(); } private static void solve() { Arrays.sort(p); p = reverse(p); int i = 0; int sum = 0; ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<iostream> #include<algorithm> #include<functional> #define MAX 1000 int main(){ int n,m,p[MAX]; while(1){ int f=0,m1=0; std::cin>>n>>m; if(n==0&&m==0) break; for(int i=0;i<n;++i){ std::cin>>p[i]; m1+=p[i]; } std::sort(p,p+n,std::greater<int>()); int c=n%m; for(int i=0;i<n-c;++i){...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <vector> #include <functional> #include <algorithm> using namespace std; typedef long long ll; int main() { int m, n; while(cin >> n >> m && n && m) { vector<int> p(n); for(int i = 0; i < n; i++) cin >> p[i]; sort(p.begin(), p.end(), gr...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<bits/stdc++.h> using namespace std; int main(){ while(1){ long long n,m; long long sum=0; cin>>n>>m; if(n==0&&m==0) break; long long p[1005]; for(int i=0;i<n;i++){ cin>>p[i]; sum+=p[i]; } sort(p,p+n,greater<long long>()); for(int i=1;i<=n;i++){ if(i%m==0)...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.*; import java.lang.*; import java.math.*; public class Main { Scanner sc = new Scanner(System.in); void run() { for (;;) { int n = sc.nextInt(); int m = sc.nextInt(); if ((n | m) == 0) { break; } int y[] = new int[n]; for (int i = 0; i < n; i++) { y[i] = sc.nextInt();...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
# -*- coding: utf-8 -*- """ Thanksgiving http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0227 """ import sys def solve(n, m, prices): ans = 0 for i in range(0, n, m): t = prices[i:i+m] if len(t) == m: t[-1] = 0 ans += sum(t) return ans def main(args): wh...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true){ int n = sc.nextInt(); int m = sc.nextInt(); if(n==0 && m==0)break; int[] p = new int[n]; for(int i=0;i<n;i++){ p[i] = sc.nextInt(); } Arrays.sort(p);...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<cstdio> #include<algorithm> #include<functional> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main(){ for(int n,m;scanf("%d%d",&n,&m),n;){ int p[1000]; rep(i,n) scanf("%d",p+i); sort(p,p+n,greater<int>()); int total=0; rep(i,n) if((i+1)%m!=0) total+=p[i]; printf("%d\n",total...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<stdio.h> int main(){ int N,M; int n[1001]={}; while(1) { int s=0; scanf("%d %d",&N,&M); if(N==0&&M==0)break; for(int i=1;i<=N;i++) scanf("%d",&n[i]); for(int i=1;i<=N;i++) for(int j=N;j>i;j--) if(n[j]>n[j-1]){int t=n[j-1];n[j-1]=n[j];n[j]=t;} for(int i=1;i<=N;i++) {if(i%M!=0)s+=n[i];} printf("%d\n",s); ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { int cnt,hukuro; int n,m,yasai[1000],total=0; while(1){ cin>>n>>m; if(n==0&&m==0)break; cnt=0; hukuro=n/m; for(int i=0;i<n;i++){ cin>>yasai[i]; } sort(yasai,yasai+n); reverse(yasai,yasai+n); for(int i=...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<bits/stdc++.h> using namespace std; const int INF = 1 << 30; int main() { int n, m, p[1000]; while(cin >> n >> m, n) { for(int i = 0; i < n; i++) { cin >> p[i]; } sort(p, p + n); int ret = accumulate(p, p + n, 0); for(int i = n - m; i >= 0; i -= m) { ret -= p[i]; } ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<cstdio> #include<algorithm> using namespace std; int main(){ int n,m; while(scanf("%d%d",&n,&m),n,m){ int yasai[1024]={0}; for(int i = 0;i < n; i++){ scanf("%d",&yasai[i]); } sort(yasai,yasai+n); for(int i = n;i >= 0; i-=m){ yasai[i] = 0;...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <algorithm> using namespace std; const int N_MAX = 1000; int n, m; int p[N_MAX]; int main () { while (cin >> n >> m, n || m) { int sum = 0; for (int i = 0; i < n; i++) { cin >> p[i]; sum += p[i]; } sort(p, p + n, greater<int>()); for (int i = m - 1; i < n; i += m) { s...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true){ final int n = sc.nextInt(); final int m = sc.nextInt...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <bits/stdc++.h> using namespace std; int main(){ int n,m; while(cin>>n>>m&&n!=0&&m!=0){ int sum=0; vector<int>data; for(int i=0;i<n;i++){ int p; cin>>p; sum+=p; data.push_back(p); } sort(data.begin(),data.end(),greater<int>()); for(int i=m-1;i<n;i+=m){ sum-=data[i]; } cout<<sum...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,m,r,i;(n=s.nextInt())>0;System.out.println(r)){m=s.nextInt();int[]a=new int[n];for(i=r=0;i<n;)r+=a[i++]=s.nextInt();Arrays.sort(a);for(i=n-m;i>=0;i-=m)r-=a[i];}}}
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <sstream> #include <cmath> #include <queue> using namespace std; int main(){ int n, m; while(true){ cin >> n >> m; if(n == 0 && m == 0){ break; } int p[200000]; long long int sum = 0; for(int i = ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <cstdio> #include <algorithm> using namespace std; bool comp(const int& a, const int& b) { return a>b; } int n, m; int p[1000]; int main() { while (scanf("%d%d",&n,&m)) { if (!n&&!m) break; for (int i=0; i<n; i++) { scanf("%d",&p[i]); } sort(p,p+n,comp); ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true){ int n = sc.nextInt(); int m = sc.nextInt(); if((n|m)==0)break; int[] a = new int[n]; int s = 0; for(int i=0;i<n;i++){ a[i] = sc.n...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
while True : n, m = map(int, input().split()) if n == 0 and m == 0 : break p = list(map(int, input().split())) p.sort(reverse=True) cst = 0 for i in range(n) : if (i+1) % m != 0 : cst += p[i] print(cst)
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <cstdio> #include <algorithm> #include <functional> using namespace std; int p[1001]; int main(void) { int N, M; unsigned long long sum; while(cin >> N >> M, N != 0 && M != 0) { sum = 0; for(int i = 0 ; i < N ; i++) cin >> p[i]; sort(p, p+N, greater<int>()); for(int i...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <vector> #include <algorithm> int main(){ int n,m; while(std::cin >> n >> m){ if(n == 0 && m == 0){ break; } std::vector<int> vegetable(n,0); for(int i = 0; i < n; ++i){ std::cin >> vegetable[i]; } std::sort(vegetable.begin(), vegetable.end(), std::greater<int>()); in...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <vector> #include <algorithm> int main(){ int n, m; // n:konyu m:hukuro std::cin >> n >> m; while(n != 0 || m != 0){ std::vector<int> price; price.resize(n); for(int i = 0; i < n; ++i){ std::cin >> price[i]; // input } std::sort(price.begin(), price.end(), std::greater<i...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<bits/stdc++.h> using namespace std; #define MAX 1000 int main() { int n, m, P[MAX], sum; while(1) { cin >> n >> m; if ( n == 0 && m == 0 ) break; sum = 0; for ( int i = 0; i < n; i++ ) { cin >> P[i]; sum += P[i]; } sort(P, P+n, greater<int>()); for ( int i = m-1; i < n; i += m ) sum -= P[...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <vector> #include <string> #include <queue> #include <map> #include <algorithm> #define INF 10000000 using namespace std; typedef pair<int,int> P; int n,m; int p[1000]; int main(){ while(1){ cin >> n >> m; if(!n&&!m){ return 0; } for(int i=0;i<n;i++){ cin >> ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <algorithm> #include <queue> #include <vector> #include <functional> #include<cstdio> using namespace std; int main(void){ int n,m; int a; while(1){ cin >> n >> m; if(n==0 && m==0)break; int ans=0; vector<int> num; for(a=0;a<n;a++){ int nn; scanf("%d",&nn); num.pus...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.*; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); while(stdIn.hasNext()) { int n = stdIn.nextInt(); int m = stdIn.nextInt(); if(n == 0 && m == 0) { break; } List<Integer> list = new ArrayList<Integer>(); for(int i ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner s = new Scanner(System.in); while(s.hasNextLine()) { int purchaceCnt = s.nextInt(); int canPackCnt = s.nextInt(); if(purchaceCnt==0 && canPackCnt==0) ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<bits/stdc++.h> using namespace std; int main(){ int n,m,sum=0,d; int p[1100]; while(1){ sum = 0; cin >> n >> m; if(n==0 && m==0) break; for(int i=0; i<n; i++) { cin >> p[i]; //sum += p[i]; } sort(p,p+n); reverse(p,p+n); for(int i=1; i<=n/m; i++) p[i*m-1]=0; ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <vector> #include <algorithm> #include <numeric> int main(){ int n, m; while(std::cin >> n >> m){ //n及びmが0ならば終了 if(n == 0 && m == 0){ return 0; } std::vector<int> p(n); for(int i = 0; i < n; ++i){ std::cin >> p[i]; } std::sort(p.begin(), p.end(), std::greater<in...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <algorithm> using namespace std; int main() { int n, m; while(1){ cin >> n >> m; if(n == 0 && m == 0) break; int p[1000]; //fill_n(p, 1000, 0); for(int i = 0; i < n; ++i) cin >> p[i]; sort(p, p + n, greater<int>()); int ans = 0; for(int i = 0; i < n; i += m){ ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,m; int a[1111]; int x=-1; while(1){ x=-1; int ans=0; cin >> n >> m;//nは購入数 mは最大数 if(n==0 && m==0)break; for(int i=0;i<n;i++){ cin >> a[i]; ans+=a[i]; } sort(a,a+n,greater<int>()); ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <algorithm> #include <iostream> using namespace std; int main() { for (;;) { int n, m, ps[1000]; cin >> n >> m; if (!n && !m) return 0; int r = 0; for (int i = 0; i < n; i++) cin >> ps[i]; sort(ps, ps+n); for (int i = 0; i < n; i++) r += ps[i]; for (int i = n % m...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <algorithm> #include <functional> using namespace std; int main(){ int n,m,fig[1001]; while(cin >> n >> m,n||m){ int ans = 0; for(int i=0;i<n;i++) cin >> fig[i]; sort(fig,fig+n,greater<int>()); for(int i=0;i<(n/m)*m;i++){ if((i+1) % m) ans += fig[i]; } for...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<iostream> using namespace std; int main(){ while(1){ int ans=0,n,m,p[1001]={}; cin>>n>>m; if(n==0 && m==0)break; for(int i=0;i<n;i++) cin>>p[i]; for(int j=0;j<n;j++) for(int i=0;i<n;i++) if(p[i]<p[i+1])swap(p[i],p[i+1]); for(int i=0;i<n;i++){ if((i+1)%m==0)p[...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include <iostream> #include <algorithm> #include <functional> #define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++) #define rep(x,to) rep2(x,0,to) using namespace std; int main(){ int m,n,p; while(cin >> m >> n, (m||n)) { int p[10000]; rep(i,m) { cin >> p[i]; } sort(p,p+m,greater<int>()); int sum = 0...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(void){ int n,m; while(cin >> n >> m,m+n){ vector<int> ps(n); for(int i = 0 ; i < n ; i ++){ cin >> ps[i]; } sort(ps.begin(),ps.end(),greater<int>()); int ans = 0; for(int i = 0 ; i < n ; i ++){ ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
while True: n, m = map(int, raw_input().split()) if n == m == 0: break data = map(int, raw_input().split()) total = [p for i,p in enumerate(sorted(data, reverse=True)) if (i+1)%m != 0] print sum(total)
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<iostream> #include<algorithm> using namespace std; int main() { int n, m, ans, p[1000]; while(1) { ans = 0; cin >> n >> m; if(m == n && !m) break; for(int i = 0; i < n; i++) cin >> p[i]; sort(p, p + n); reverse(p, p + n); for(int i = 0; i < n; i++) { ...
Problem: As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three good friends living in the Matsunaga housing complex bloom...
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; int main(){ int n,m,data[1001]; while(cin>>n>>m&&n|m){ int sum=0; for(int i=0;i<n;i++){ cin>>data[i]; sum+=data[i]; } sort(data,data+n,greater<int>()); for(int i=m-1;i<n;i+=m)sum-=data[i]; ...