【京东】题目死长死长的那个小山烽火台题



package com.company;


import java.util.Scanner;

public class Main {
    public static boolean canSee1(int[] a, int x, int y) {
        int len = a.length;
        boolean ret = true;
        for (int i = x + 1; i < y; i++) {
            if (a[i] > a[x] || a[i] > a[y]) {
                ret = false;
                break;
            }
        }

        return ret;
    }

    public static boolean canSee2(int[] a, int x, int y) {
        int len = a.length;
        boolean ret = true;
        for (int i = y + 1; i < len ; i++) {
            if (a[i] > a[x] || a[i] > a[y]) {
                ret = false;
                break;
            }
        }
        for (int i = 0; i < x; i++) {
            if (a[i] > a[x] || a[i] > a[y]) {
                ret = false;
                break;
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int[] h = new int[n];
            int count = 0;
            for (int i = 0; i < n; i++) {
                h[i] = scanner.nextInt();
            }
            for (int i = 0; i < n - 1; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (canSee1(h, i, j) || canSee2(h, i, j)) {
                        count++;
                    }

                }
            }
            System.out.println(count);

        }
    }
}
我特么以为9点10分交卷,没有提交上代码。。。。。真是头号大**。。。。。。大家帮我Review一下代码呗
全部评论
http://codeforces.com/contest/5/problem/E 原题
点赞 回复 分享
发布于 2016-09-05 22:42
你还记得给的测试数据吗?有的话给我呗!谢谢啊!
点赞 回复 分享
发布于 2016-09-05 22:28
这排版。。。
点赞 回复 分享
发布于 2016-09-05 22:15

相关推荐

Southyeung:我说一下我的看法(有冒犯实属抱歉):(1)简历不太美观,给我一种看都不想看的感觉,感觉字体还是排版问题;(2)numpy就一个基础包,机器学习算法是什么鬼?我感觉你把svm那些写上去都要好一点。(2)课程不要写,没人看,换成获奖经历;(3)项目太少了,至少2-3个,是在不行把网上学习的也写上去。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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