pdd笔试Java 全部AC



public class Main1 {  static HashMap<Integer, Integer> map;  static int[] res;  public static void main(String[] args) {
        Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  map = new HashMap<>(); int max = 0; for (int i = 0; i < n; i++) {  int tmin = in.nextInt(); int tmax = in.nextInt(); map.put(tmin, map.getOrDefault(tmin, 0) + 1); map.put(tmax + 1, map.getOrDefault(tmax + 1, 0) - 1);
            max = Math.max(max, tmax + 1);
        } res = new int[102]; //-50 -- +50    int sum = 0; int start = -1; int end = -1; for (int i = 0 ; i <= 101; i++) {
            sum += map.getOrDefault(i - 50, 0); res[i] = sum; if (sum >= k && start == -1) {
                start = i - 50;
            } else if (sum >= k && start != -1 && i != 101){
                end = i - 50;
            }
        } if (start != -1 && end != -1) {
            System.out.println(start + " " + end);
        } else {
            System.out.println("error");
        }
    }
}
public class Main2 {  public static void main(String[] args) {
        Scanner in = new Scanner(System.in);  String[] time = in.next().split(":");  double min = Double.parseDouble(time[1]); double hour = Double.parseDouble(time[0]) % 12; double diff = Math.abs(5.5 * min - 30 * hour);
        DecimalFormat df = new DecimalFormat("##.#");
        diff = diff > 180 ? 360 - diff : diff;
        System.out.println(df.format(diff));
    }
}
public class Main3 { static int[] x; static int[] y; public static void main(String[] args) {
        Scanner in = new Scanner(System.in); int n = in.nextInt(); x = new int[n]; y = new int[n]; int count = 0; for (int i = 0; i < n; i++) { x[i] = in.nextInt(); y[i] = in.nextInt(); for (int j = 1; j < i; j++) { for (int k = 0; k < j; k++) { if (det(x[i], y[i], x[j], y[j], x[k], y[k]) == 0) { continue;
                    } else {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    } private static int det(int x1, int y1, int x2, int y2, int x3, int y3) { return x1 * (y2 - y3) - y1 * (x2 - x3) + 1 * (x2 * y3 - y2 * x3);
    }
}
public class Main4 { public static void main(String[] args) {
        Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] res = new int[n];
        Deque<Integer> max = new ArrayDeque<>();
        Deque<Integer> min = new ArrayDeque<>();
        StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) {
            res[i] = in.nextInt(); while (!max.isEmpty() && max.peek() < i - k + 1) {
                max.poll();
            } while (!max.isEmpty() && res[max.peekLast()] < res[i]) {
                max.pollLast();
            }
            max.offer(i); while (!min.isEmpty() && min.peek() < i - k + 1) {
                min.poll();
            } while (!min.isEmpty() && res[min.peekLast()] > res[i]) {
                min.pollLast();
            }
            max.offer(i);
            min.offer(i); if (i >= k - 1) { int diff = res[max.peek()] - res[min.peek()];
                sb.append(diff + " ");
            }
        }
        System.out.println(sb.toString().trim());
    }
}

顺序记不清了 第一个是温度计 第二个是时间角度 第三个是三角形 第四个是滑窗

#笔试题目#
全部评论
实验室大佬也AK了,好像没啥用,挺多人都全做出来了/给跪了
点赞 回复 分享
发布于 2018-04-04 21:42
可以说是很牛逼了
点赞 回复 分享
发布于 2018-04-03 18:21
可否调一下上传格式,这样看着好别扭~
点赞 回复 分享
发布于 2018-04-03 19:03
第一题有考虑区间不连续,比如[1,2,3][5,6]取[1,2,3]这个区间吗?
点赞 回复 分享
发布于 2018-04-04 21:13

相关推荐

美丽的查理斯不讲武德:包kpi的啊,感觉虾皮一点hc都没有
点赞 评论 收藏
分享
头像
11-18 16:08
福州大学 Java
影流之主:干10年不被裁,我就能拿别人一年的钱了,日子有盼头了
点赞 评论 收藏
分享
11-24 00:11
已编辑
广东工业大学 算法工程师
避雷深圳&nbsp;&nbsp;yidao,试用期&nbsp;6&nbsp;个月。好嘛,试用期还没结束,就直接告诉你尽快找下一家吧,我谢谢您嘞
牛客75408465号:笑死,直属领导和 hr 口径都没统一,各自说了一些离谱的被裁理由,你们能不能认真一点呀,哈哈哈哈哈😅😅😅
点赞 评论 收藏
分享
评论
4
14
分享
牛客网
牛客企业服务