NC207669. ShootingGame
描述
输入描述
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)