360第二题 最后没提交啊,不知道对不对,求哪位大神看看

import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int[] arr = new int[T];
for (int i = 0; i < T; i++) {
int[] tm = new int[3];
tm[0] = sc.nextInt();
tm[1] = sc.nextInt();
tm[2] = sc.nextInt();
Arrays.sort(tm);
while (tm[2]>=2 && tm[1]>=1) {
tm[2] -= 2;
tm[1] -= 1;
arr[i]++;
Arrays.sort(tm);
}
if (tm[0]==1 && tm[1]==1 && tm[2]==1) {
arr[i]++;
}
}
sc.close();
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
}

#实习##笔试题目#
全部评论
三个数先比较出大中小。如果大>中*2+小*2,结果是中+小,否则结果是(大+中+小)/3
点赞 回复 分享
发布于 2018-03-31 21:57
超时,不用看。。。。
点赞 回复 分享
发布于 2018-03-31 21:53
会超时的,因为我也是这样……
点赞 回复 分享
发布于 2018-03-31 21:46
感觉这么做会超时,我第一个方法是这样做的然后40超时
点赞 回复 分享
发布于 2018-03-31 21:42

相关推荐

完美的潜伏者许愿简历通过:我上表jd,请求封我做后端大将军的事,北京有消息了:竟然不许!!! 他们一定是看我没有实习,这才故意驳回我的请求!
点赞 评论 收藏
分享
04-29 22:35
门头沟学院 Java
牛友说改了名字能收到offer:旧图新发查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务