列表

详情


NC207669. ShootingGame

描述

One day, Li Lei and Han Meimei want to hold a shooting game.
Competition rules:
1.There are three kinds of targets. Red : one point, White : two points, Black : three points.
2.The winner is the first in the competition.
Now Li Lei and Han Meimei are not good at mathematic, so they need your help.

输入描述

First,you will be given a number N,represents the number of competitors.
Given a list about competititor's ID(form 1 to N), the number of red targets, White targets and Black targets.
The number of competitiors will not exceed 100.

输出描述

You need output the winner's ID and total points. If there are more than one winners, please output the winner with the smallest ID.

示例1

输入:

5
1 8 3 7
2 6 2 4
3 6 5 0
4 2 6 3
5 1 6 8

输出:

5 37

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++(clang++ 11.0.1) 解法, 执行用时: 3ms, 内存消耗: 496K, 提交时间: 2023-02-03 19:06:32

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,max=0,id=0;
	cin>>n;
	while(n--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(max<b+2*c+3*d){
			max=b+2*c+3*d;
			id=a;
		}
	}
	cout<<id<<" "<<max;
} 

C(clang 3.9) 解法, 执行用时: 3ms, 内存消耗: 376K, 提交时间: 2020-06-07 14:19:47

#include<stdio.h>

int main()
{
int t,max=0,id,a,b,c,d;
scanf("%d",&t);
while(t--){
scanf("%d%d%d%d",&a,&b,&c,&d);
if(b+c*2+d*3>max){
max=b+c*2+d*3;
id=a;
}
}
printf("%d %d\n",id,max);
    return 0;
}

pypy3(pypy3.6.1) 解法, 执行用时: 59ms, 内存消耗: 18660K, 提交时间: 2020-06-07 16:30:50

n = int(input())
sum = 0
for _ in range(n):
    a = list(map(int, input().split()))
    if a[1] + a[2] * 2 + a[3] * 3 > sum:
        sum = a[1] + a[2] * 2 + a[3] * 3
        id = _
print(id + 1, sum)

Python3(3.5.2) 解法, 执行用时: 30ms, 内存消耗: 3544K, 提交时间: 2020-06-07 13:20:36

s=[]

for i in range(int(input())):
    n,a,b,c=map(int,input().split())
    s.append(a+b*2+c*3)
    
o = max(s)

print((s.index(o)+1) , o)

上一题