prompt string | response string |
|---|---|
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence... | #include<iostream>
#include<vector>
#include<utility>
#include<bitset>
#include<functional>
using namespace std;
int main(int argc, char *argv[])
{
for(int t = 1;; t++) {
int n, m;
cin >> m >> n;
if(n == 0) break;
vector<int> os;
for(int i = 0; i < n; i++) {
string str;
cin >> str;
... |
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence... | #include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1 << 30;
void chmin(int &a, int b){
a = min(a, b);
}
int cnt[1<<11][1<<11], dp[1<<11][1<<11];
int solve(){
int m, n;
cin >> m >> n;
if(m==0) return 1;
vector<int> a(n);
for(int i=0;i<n;i++){
string s;
cin >> s;... |
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence... | #include <bits/stdc++.h>
using namespace std;
int pow3[12] = {1}, n, m;
int dp[177147], cnt[177147];
int edcode(vector<int> S) {
int ans = 0;
for (int i = 0; i < 11; ++i) {
ans += S[i] * pow3[i];
}
return ans;
}
vector<int> decode(int S) {
vector<int> ans;
for (int i = 0; i < 11; ++i, S /= 3) {... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <bits/stdc++.h>
using namespace std;
int cnt[45][45] = {0};
long double dis[45][45] = {0};
long double sum[45][45] = {0};
int m, n, x;
long double ans = 1;
long double solve();
int main() {
cout << fixed << setprecision(12);
int t;
for(t = 0; t < 2; ++t) {
cin >> m >> n >> x;
ans *= solve();
... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-7;
//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long double ldouble;
ldouble calc(int m, int n, int x) {
// n / (m + n), m / (m + n)
ldouble len[50][50] = {};
len[0][0] = 1.0L;
for(int i = 0; i <= x; i++) {
for(int j = 0; j <= x; j++) {
... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include "bits/stdc++.h"
using namespace std;
using ld = long double;
const ld eps = 1e-7;
ld getans(ld l,ld r, int b,ld c) {
if (b == 0||abs(r-l)<eps) {
return (1-l)*(r - l);
}
ld aa = getans(l,(1-c)*l+c*r, b - 1, c);
ld ab = getans((1 - c)*l + c*r,r, b - 1, c);
return aa + ab;
}
ld get() {
int m, n, x; cin ... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <cstdio>
#include <queue>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long double ld;
int m, n, x, k, l, y;
ld side(ld a, int k){
if(k == 0){
return 1;
}
return (2 * a * a - 2 * a + 1) * side(a, k - 1) + a * (1 - a);
}
int main(){
scanf("%d%d%d%d... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define repl(i,a,b) for(int (i)=(int)a;(i)<(int)(b);++(i))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cerr<<#x<<"="<<x<<endl
long doubl... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | m,n,x=[int(i) for i in input().split()]
k,l,y=[int(i) for i in input().split()]
res=0.5*(1.0+((m**2+n**2)**x)/((m+n)**(2*x)))
res*=0.5*(1.0+((k**2+l**2)**y)/((k+l)**(2*y)))
print(res)
|
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),... |
Problem: Notes
For this problem, it is recommended to use floating point numbers, which are more accurate than double.
Input
m n x
k l y
For input, six integers m, n, x, k, l, y are given in the above input format.
These six integers correspond to those in the problem statement, repeating the horizontal m: n cu... | #include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
N,M = map(int,input().strip().split(" "))
if [N,M] == [0,0]:
break
L = []
S = 0
for i in range(N):
l = list(map(int,input().strip().split(" ")))
l.reverse()
L.append(l)
S = S + l[0]*l[1]
L.sort()
for j in range(0,N):
t = N-j-1
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <functional>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n, m;
while (cin >> n >> m, n){
vector<pair<int, int> > dp;
for (int i = 0; i < n; i++){
int d, p;
cin >> d >> p;
dp.push_back(make_pair(p, d));
}
sort(dp.begin(), dp.end(), greater... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
int n,m,i,d,p,z;
int main(){
while(std::cin>>n>>m,n){
int x[11]={};
for(z=i=0;i++<n;x[p]+=d,z+=d*p)std::cin>>d>>p;
for(i=10;i>=0;--i)
if(x[i]<m)z-=x[i]*i,m-=x[i];
else if(x[i])z-=i*m,m=0;
std::cout<<z<<'\n';
}
} |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
while(1){
int N,M;
long ans=0;
cin >> N >> M;
pair<int,int> X[N];
if(N==0&&M==0) break;
for(int i=0;i<N;++i) cin >> X[i].second >> X[i].first;
sort(X,X+N);
reverse(X,X+N);
for(int i=0;i<N... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.util.*;
public class Main{
class C implements Comparable<C>{
int d,p;
public C(int d, int p) {
this.d = d;
this.p = p;
}
@Override
public int compareTo(C o) {
if(this.p < o.p) return 1;
if(this.p > o.p) return -1;
return 0;
}
}
private void doit(){
Scanner sc = new Sca... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (true) {
long n = stdIn.nextLong();
long m = stdIn.nextLong();
if(n == 0 && m == 0) break;
Long[] c = new Long[11];
for (int i = 0; i < 11; i++) {
c[i] = 0L;
}
for... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
using namespace std;
int N,M;
pair<int,int> PD[10010];
int main()
{
while(cin >>N >> M && N)
{
int d,p;
for(int i = 0;i<N;i++)
{
cin >> d;
cin >> p;
PD[i] = make_pair(p,d);
}
sort(PD,PD+N);
int S=0;
for(int i=0;... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int N, M;
while(cin >> N >> M && N){
int d, p, dp[11];
for(int i=0; i<11; ++i) dp[i] = 0;
for(int i=0; i<N; ++i){
cin >> d >> p;
dp[p] += d;
}
int ex = 0;
for(int i... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | public class Main{
public void run(java.io.InputStream in, java.io.PrintStream out){
java.util.Scanner sc = new java.util.Scanner(in);
int n, m, i, j, tmp, sum;
int[] d, p;
for(;;){
n = sc.nextInt(); m = sc.nextInt();
if(n == 0 && m == 0)break;
d = new int[n]; p = new int[n];
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import sys
while True:
n,m = [int(i) for i in input().split()]
if n == 0 and m == 0:
sys.exit()
dp = []
ans = 0
for i in range(n):
dp.append([int(j) for j in input().split()])
dp.sort(key=lambda x:x[1],reverse=True)
for i in range(n):
if dp[i][0] <= m:
m ... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | 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 boolean debug = false;
static boolean solve() {
int n = in.nextInt();
int m = in.nex... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>
using namespace std;
int main(){
while(true){
long long int N, M;
cin >> N >> M;
if(N == 0 && M == 0){
break;
}
long long int a[20];
for(int i = 0; i < 20; i+... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <map>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(void)
{
long n, m;
while(cin >> n >> m, n > 0){
map<long, long> pd;
long ans=0;
//map pdを構成
rep(i, n){
int d, p;
cin >> d >> p;
if (pd.count(p) == 0){
pd.insert(make_pair(p, d));
}e... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
n,m=map(int,input().split())
matrix=[]
if n==m==0:
break
else:
for i in range(n):
D,P=map(int,input().split())
matrix.append([D,P])
matrix.sort(key = lambda x:x[1],reverse=True)
i=0
while m>0 and i<=n-1:
pp=matrix[i][1]
dd=matrix[i][0]
if dd > m:
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
using namespace std;
int main(){
int n,m;
while(cin>>n>>m,n){
int a[11]={0};
for(int i=0;i<n;i++){
int b,c;
cin>>b>>c;
a[c]+=b;
}
int ans=0;
for(int i=10;i>=0;i--){
if(m-a[i]>=0) m-=a[i];
else{
ans+=i*(a[i]-m);
m=0;
}
}
cout<<ans<<endl;
}
} |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<sstream>
#include<iomanip>
using namespace std;
#define INF 999999999
int main(){
int ans, i, j, k, n, m, d, p, dis;
int at[11];
while(1){
cin >> n >> m;
if(!n) break;
for(k=0;k<=10;k++)at[k] ... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.util.Scanner;
public class Main {
static int calcExpectation(int[][] memo, int dis, int money) {
for(int r = 0; r < memo.length; r++) {
int max = memo[0][1];
int minusDis = memo[0][0], idx = 0;
for(int c = 1; c < memo.length; c++) {
if(memo[c][1] > max) {
max = memo[c][1];
minu... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
pass
def solve(self):
'''
insert your code
'''
while True:
n, m = map(... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int N, M, D[10005], P[10005];
while( cin >> N >> M, N|M ){
for(int i=0; i<N; i++){
cin >> D[i] >> P[i];
}
for(int i=0; i<N; i++){
for(int j=1; j<N; j++){
if( P[j-1] < P[j] ){
int tmp = P[j-1];
P[j-1] = P[j];
P[j... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | 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[] d = new int[n];
int[] p = new int[n];
for (int i = 0; i < n; i++) {
d[i] = s... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
int N,M;
int S;
pair<int,int>PD[10010];
int main()
{
while(cin>>N>>M&&N)
{
int d,p;
for(int i=0;i<N;i++)
{
cin>>d>>p;
PD[i]=make_pair(p,d);
}
sort(PD,PD+N);
S=0;
for(... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int n,m;
int main() {
while(cin >> n >> m && n > 0)
{
pair<int, int> pd
[10000];
int d,p;
int y = 0;
for(int i = 0; i < n; i++)
{
cin >> d >> p;
pd[i] = make_pair(p, d);
y += d*p... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(true){
int N = sc.nextInt();
int M = sc.nextInt();
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<bits/stdc++.h>
int d[11],n,m,i,a,b,s,e;
int main(){
while(true) {
memset(d,0,sizeof(d));s=0;
std::cin>>n>>m;if(!n){break;}
for(i=0;i<n;i++){std::cin>>a>>b;d[b]+=a;}
for(i=10;i>=0;i--){e=std::min(d[i],m);m-=e;s+=i*(d[i]-e);}
printf("%d\n",s);}
} |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
n, m = map(int, input().split())
if n == 0:
break
else:
s = 0
l = []
for _ in range(n):
d, p = map(int, input().split())
s += d * p
l.append((p,d))
l.sort()
while m > 0 and l:
a, b = l.pop()
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | # coding: utf-8
while 1:
data=[]
n,m=map(int,input().split())
if n==m==0:
break
for i in range(n):
d,p=map(int,input().split())
data.append((d,p))
data=sorted(data,key=lambda x:(-x[1],-x[0]))
for i in range(n):
if data[i][0]<=m:
m-=data[i][0]
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
(n, m) = list(map(int, input().split()))
if n == 0:
break
sec = []
for j in range(n):
sec.append(list(map(int, input().split())))
sec.sort(key=lambda x: x[1], reverse=True)
res = 0
for e in sec:
if e[0] <= m:
m -= e[0]
elif m == 0:
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | // AOJ 2019 "お姫様の嫁入り" (ICPC模擬国内予選 2008 Problem B)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
final int MAX_P = 10;
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
int m = sc.nextInt();
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <cstdio>
#include <iostream>
#include <algorithm>
#define F first
#define S second
using namespace std;
int n;
long long m;
int d;
int p;
pair<int,int> a[11111];
int main(void){
while(cin >> n >> m){
if(!n) break;
for(int i = 0; i < n; i++){
cin >> d >> p;
a[i] = make_pair(p,d);
}
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <utility>
#include <algorithm>
#include <iostream>
using namespace std;
int N, M;
pair<int, int> PD[10010];
int main() {
while (cin >> N >> M && N) {
int d, p;
for (int i=0; i<N; ++i) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort (PD, PD+N);
reverse(PD, PD+N); // sor... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n,m;
while(cin>>n>>m,n){
int data[11]={0};
for(int i=0;i<n;i++){
int d,p;
cin>>d>>p;
data[p]+=d;
}
int ans=0;
for(int i=10;i>0;i--){
if(data[i]<=m){
m-=data[i];
data[i]=0;
}else{
data[i]-=m;
m=0... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<bits/stdc++.h>
using namespace std;
int d[10000];
int main(){
while(1){
int n,m;
cin >> n >> m;
if(n==0 and m==0) break;
pair<int,int> p[n];
for(int i=0;i<n;i++){
cin >> p[i].second >> p[i].first;
}
sort(p,p+n);
for(int i=n-1;i>=0;i--){
if(p[i].second<m){
m-=p[i].se... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | from operator import itemgetter
def protect(N,M):
DP = []
for i in range(N):
DP.append(list(map(int, input().split())))
DP.sort(key=itemgetter(1))
nokori = 0
for i in range(N):
if M > DP[N - i - 1][0]:
M -= DP[N - i - 1][0]
DP.pop()
elif M <= DP[N ... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #! /usr/bin/python
# -*- coding: utf-8 -*-
(n, m) = map(int, raw_input().split())
while n!=0:
Sum = 0
pd = []
for i in range(n):
(d, p) = (map(int, raw_input().split()))
Sum += d*p
pd.append([p, d])
pd.sort(reverse=True)
red = 0
for i in range(n):
if m >= pd[i][1... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int N, M;
pair<int,int> PD[10010];
int main(){
while(cin >> N >> M && N){
int d, p;
for (int i=0; i<N; ++i){
cin >> d >> p;
PD[i] = make_pair(p,d);
}
sort(PD,PD+N,greater<pair<int,int>>());
int S = 0;
for (int i=0; i<N... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
int N,M;
P p[10003];
int main(){
while(1){
scanf("%d %d",&N,&M);
if(!N && !M) break;
for(int i=0;i<N;i++)... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n,m;
while(1){
cin>>n>>m;
if(!n&&!m)break;
int data[11];
memset(data,0,sizeof(data));
while(n--){
int d,p;
cin>>d>>p;
data[p]+=d;
}
int k=11,ans=0;
while(--k){
if(data[k]>0){
if(data[k]>=m){
data[k]-=m;
for(int i=k... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int n;
long long m;
long long c=0;
while(1){
c=0;
cin >> n >> m;
if(n==0&&m==0)break;
pair<int,int> a[10000];
for(int i=0;i<n;i++){
cin >> a[i].second>>a[i].first;
c+=a[i].first*a[i].second... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.TreeSet;
im... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;
int n, m;
P x[10000];
void solve(){
rep(i,n) cin >> x[i].second >> x[i].first;
sort(x,x+n,greater<P>());
int ans = 0;
rep(i,n){
if(m >... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.util.Arrays;
import java.util.Scanner;
public class Main {
MyScanner sc = new MyScanner();
Scanner sc2 = new Scanner(System.in);
final int MOD = 1000000007;
int[] dx = { 1, 0, 0, -1 };
int[] dy = { 0, 1, -1, 0 };
void run() {
for (;;) {
int N = sc.nextInt();
int M = sc.nextInt();
if ((N |... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<bits/stdc++.h>
int n,m,i,d,p,z;
int main(){
while(std::cin>>n>>m,n){
int x[11]={};
for(z=i=0;i++<n;x[p]+=d)std::cin>>d>>p;
for(i=10;i>=0;z+=i*x[i],--i)x[i]-=d=(x[i]<m?x[i]:m),m-=d;
std::cout<<z<<'\n';
}
} |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<algorithm>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> p;
typedef pair<int,p> pip;
int main(){
int n,m;
while(cin>>n>>m,n||m){
int pin,din;
pip d[n];
rep(i,n){
cin>>din>>pin;
d[i]=pip(pin,p(... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,a,b,ans;
while(1){
cin>>n>>m;
if(n==0) break;
ans=0;
vector<pair<int,int> > D;
for(int i=0;i<n;i++){
cin>>b>>a;
D.push_back(make_pair(a,b));
}
sort(D.begin(),D.end(),greater<pair<int,int> >());
for(int i=0;i<n;i++){
if(m<0) m=... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class zone{
public:
int d,p;
zone(int d,int p):d(d),p(p){}
};
bool operator < (zone a,zone b){
return a.p>b.p;
}
int main()
{
int n;
long long m;
while(cin>>n>>m && n!=0){
vector<zone> V;
for(int i=0;i<n;i++){
int d,p; cin>>d>... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RALL(x) (x).rbegin(),(x).rend()
#define F first
#define S second
void solve(int n, int m) {
vector<pair<int,int>> data(n); // (p,d)
for(auto& i : data) cin >> i.S >> i.F;
sort... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<algorithm>
#include<iostream>
using namespace std;
int N,M;
pair<int,int> PD[10010];
int main()
{
while(cin >> N >> M && N)
{
int d,p;
for(int i=0;i<N;i++)
{
cin >> d >>p;
PD[i]=make_pair(p,d);
}
sort(PD,PD+N);
int S=0;
f... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import static java.lang.Integer.parseInt;
/**
* Princess's Marriage - Accepted
*/
public class Main {
public static void main(String[] args) throws IOException {
Buf... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
for(int n, m; cin >> n >> m, n;) {
vector<int> cnt(11, 0);
for(int i = 0; i < n; ++i) {
int d, p;
cin >> d >> p;
cnt[p] += d;
}
int ans = 0;
for(int i = 10; i > 0;... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | // 2016-12-06
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
struct section { int d, p; };
int main() {
int n, m, d, p;
vector<section> v;
while (cin >> n >> m, n) {
v.clear();
for (int i = 0; i < n; i++) {
cin >> d >> p;
section s = {d, p};
v.push_bac... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
void solve(int n, int m){
int sum = 0;
int ans = 0;
vector<P> v;
for(int i=0; i<n; ++i){
int d, p;
cin >> d >> p;
v.push_back(P(p, d));
}
sort(v.begin(), v.end());
for(int i=n-1; i>=0; --i){
int d = v[i].second;
int p ... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int N, M;
while(cin >> N >> M && (N|M)) {
vector<pair<int, int> > vec;
int expect = 0;
for(int i=0; i<N; i++) {
int d, p;
cin >> d >> p;
vec.push_back(make_pair(p, d));
expect += d * p;... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<cstdio>
#define MIN(X,Y) ((X<Y)?(X):(Y))
int main(void) {
while(true) {
int n,m,dis[11]={};
scanf("%d%d",&n,&m);
if(!n) break;
for(int i=0; i<n; i++) {
int d,p;
scanf("%d%d",&d,&p);
dis[p] += d;
}
for(int i=10; i; i--) {... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int n, m;
P info[10001];
int main()
{
while (cin >> n >> m, n || m) {
long long ans = 0;
for (int i = 0; i < n; i++)
cin >> info[i].second >> info[i].first;
sort(inf... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
n, m = map(int, input().split())
if n == 0:break
l = []
for i in range(n):
l.append(list(map(int, input().split())))
l.sort(key=lambda x:x[1])
l.reverse()
for i in range(n):
if m >= l[i][0]:
m -= l[i][0]
l[i][0] = 0
elif m != 0:
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import static java.lang.Integer.parseInt;
/**
* Princess's Gamble
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader b... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
public class Main{
static PrintWriter out... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
N, M = map(int, input().split())
if N == 0 and M == 0: break
travel = [tuple(map(int, input().split())) for _ in range(N)]
travel.sort(reverse=True, key=lambda x:x[1])
for i, (d, p) in enumerate(travel):
if M == 0: break
travel[i] = (p, max(0, d-M))
M = max(0, M-d... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n,m;
while(cin>>n>>m){
if(n==0&&m==0) break;
int d[n],p[n];
for(int i=0;i<n;i++){
cin>>d[i]>>p[i];
}
int pm=0,nowp;
while(m>0){
for(int i=0;i<n;i++){
pm=max(pm,p[i]);
if(pm==p[i]) nowp=i;
}
if(pm==0) break;
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while 1:
N,M = map(int,raw_input().split())
if N == M == 0: break
DP = [map(int,raw_input().split()) for _ in xrange(N)]
DP = sorted(DP, key = lambda x:x[1])[::-1]
ans = 0
for i in xrange(N):
ans += DP[i][1]*max(0,DP[i][0]-M)
M = max(0,M-DP[i][0])
print ans |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF()... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
#define fi first
#define se second
signed main()
{
int N, M;
Pi data[10005];
while(cin >> N >> M, N || M) {
int sum = 0;
Rep(i, N) {
cin >> data[i].se >... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
using namespace std;
int main(){
long long int m;
int n, d[10000];
short p[10000];
bool f;
while( cin>>n>>m && (n||m) ){
for( int i=0;i<n;i++ )
cin >> d[i] >> p[i];
do{
f=false;
for( int i=1;i<n;i++ )
if( p[i-1]<p[i] ){
int dd=d[i]; d[i]=d[i-1]; d[i-1]=dd;
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... |
while True:
n, m = map(int, input().split())
if (n, m) == (0, 0):
break
dp = [list(map(int, input().split())) for i in range(n)]
dp = sorted(dp, key=lambda kv:kv[1], reverse=True)
r = 0
for d,p in dp:
if m >= d:
m -= d
else:
r += p*(d-m)
m = 0
print(r) |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
while (cin >> n >> m, n) {
vector<int> cnt(11);
while (n--) {
int d, p; cin >> d >> p; cnt[p] += d;
}
for (int p = 10; p >= 0; p--) {
int sub = min(m, c... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
int main(){
int N, M;
while(cin >> N >> M, N|M){
vector<pair<int, int> > way;
rep(i, N){
int D, P;
cin >> D ... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #if 0
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int N, M;
pair<int,int> PD[10010];
int main() {
while (cin >> N >> M && N) {
int d, p;
for (int i=0; i<N; ++i) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD, PD+N, greater<pair<int,int>>());
i... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.util.*;
class Main {
static void solve (int n, int m, ArrayList<Integer> d, ArrayList<Integer> p) {
OUTER:
while (m > 0 && (!p.isEmpty()) ) {
int pMax = Collections.max(p);
for (int i = 0; i < p.size(); i++) {
if (p.get(i) == pMax) {
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... |
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.awt.geom.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main{
static final Reader sc = new Reader();
static final PrintWriter out = new PrintWriter(System.out,false);
public static void main... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
typedef pair<int, int> P;
int main() {
int n;
long long m;
while(cin >> n >> m && (n || m)){
priority_queue<P> que;
int d, p;
for(int i = 0; i < n; ++i){
cin >> d >> p;
que.p... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<algorithm>
using namespace std;
struct I{
int d,p;
};
bool operator>(const I &a,const I &b){
return a.p!=b.p?a.p>b.p:a.d>b.d;
}
int main(){
int n,m,ans,t,c;
I i[10000];
while(cin>>n>>m,n){
ans=t=0;
for(int j=0;j<n;j++)cin>>i[j].d>>i[j].p,ans+=i[j].d*i[j].p;
sort(i,i+n,greater<I>()... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
long long int n,m;
while(cin >>n>>m,n||m){
vector<pair<long long int, long long int> > road;
for(int i=0,a,b; i<n; i++){
cin >>a>>b;
road.push_back(make_pair(b,a));
}
long long int ans ... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <algorithm>
#include <utility>
#include <iostream>
using namespace std;
int N, M;
pair<int,int> PD[10010];
int main() {
while (cin >> N >> M && N) {
int d, p;
for (int i=0; i<N; ++i) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD, PD+N);
reverse(PD, PD+N);
int ans = 0;
for (int i=0; i... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
N,M = map(int,input().split(" "))
if N==0 and M==0:
break
P = [list(map(int,input().split(" "))) for i in range(0,N)]
ans = 0
for p in sorted(P,key=lambda x:x[1],reverse=True):
ans += (p[0] - M)*p[1] if p[0] - M > 0 else 0
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
class Solve{
final Scanner in = new Scanner(System.in);
boolean solve(){
int n = in.nextInt();
int m = in.nextInt();
if(n =... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | # coding: utf-8
n,m=map(int,input().split())
while n!=0:
d=[]
p=[]
for i in range(n):
d_i,p_i=map(int,input().split())
d.append(d_i)
p.append((p_i,i)) #タプルでインデックス情報を付加
#警備がいない場合の期待値を求める
hazard=0
for i in range(n):
hazard+=d[i]*p[i][0]
#単位長さあたりの... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<stdio.h>
#include<algorithm>
using namespace std;
pair<int,int> v[10000];
int main(){
int a,b;
while(scanf("%d%d",&a,&b),a){
int ret=0;
for(int i=0;i<a;i++){
int c,d;
scanf("%d%d",&c,&d);
ret+=c*d;
v[i]=make_pair(-d,c);
}
std::sort(v,v+a);
for(int i=0;i<a;i++){
if(b>=v[i].second){
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import static java.lang.Integer.parseInt;
/**
* Princess's Marriage - Accepted
*/
public class Main {
public static void main(String[] args) throws IOException {
Buf... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
n, m = map(int, input().split())
if n == 0:
break
risks = [(p, d) for d, p in (map(int, input().split()) for _ in range(n))]
risks.sort()
remain = 0
while risks:
p, d = risks.pop()
if d >= m:
remain = p * (d - m)
break
m -= d
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
n, m = map(int, input().split())
dpList = []
if (n,m) == (0,0):
break
for i in range(n):
row = list(map(int,input().split()))
dpList.append(row)
dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
num = 0
for i in range(n):
if m >= dpList[... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <utility>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int N, M;
while(cin >> N >> M && N){
int d, p;
pair<int, int> PD[10010];
for(int i=0; i<N; ++i){
cin >> d >> p;
PD[i] = make_pair(p, d);
}
... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | 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();// P̨©Ë
if (n == 0 && m == 0) {
break;
}
int c = 0;
int dp[][] = new int[n][2];
for (int i = 0... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | while True:
n, m = map(int, input().split())
if n == 0:
break
lst = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:-x[1])
ans = 0
for d, p in lst:
if m >= d:
m -= d
else:
ans += (d - m) * p
m = 0
print(ans)
|
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | import java.util.Arrays;
import java.util.Scanner;
public class Main {
private static class Path implements Comparable<Path>{
int dist;
int p;
Path(int d, int p){
this.dist = d;
this.p = p;
}
@Override
public int compareTo(Path arg0) {
return this.p > arg0.p ? -1
: this.p < arg0.... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
int N, M;
pair<int, int> PD[10010];
int main() {
while (cin >> N >> M && N)
{
int d, p;
for (int i = 0; i < N; ++i)
{
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD, PD + N);
reverse(PD, PD... |
Problem: Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent mor... | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, m;
while (cin >> n >> m, n) {
int cnt[11] = {};
int d, p;
for (int i = 0; i < n; i++) {
cin >> d >> p;
cnt[p] += d;
}
for (int i = 10; i >= 0; i--) {
if (m < cnt[i]) {
cnt[i] -= m;
m = 0;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.