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

相关推荐

不愿透露姓名的神秘牛友
07-16 12:18
点赞 评论 收藏
分享
想按时下班的大菠萝在...:隔壁学校的,加油多投, 实在不好找可以下个学期开学找,把算法八股准备好,项目有空再换换
投了多少份简历才上岸
点赞 评论 收藏
分享
07-14 12:29
门头沟学院 Java
后端岗,实习三周感觉有点想跑路了,担心秋招被拉黑,有没有佬是字节HR知道情况的
从零开始的转码生活:你实习三周都想跑路,将来拿到offer真的愿意在这干十几二十年吗
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务