Java在洛谷还能活下去吗。

P1440 求m区间内的最小值

fancy。 @ 2020-04-06 15:20:42

单调队列的题全被卡,全是MLE。。

模板题也是,这个题也是,我吐了,我就开了2个数组!

import java.io.*;
import java.util.*;
public class Main {
    static int N = 2000010;
    static int n,m;
    static int num[] = new int[N];
    static int min[] = new int[N];
    static Deque<Integer> q = new LinkedList<Integer>(); 
    public static void main(String[] args) throws IOException{
        StreamTokenizer re = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter pr = new PrintWriter(new OutputStreamWriter(System.out));
        re.nextToken(); n = (int)re.nval;
        re.nextToken(); m = (int)re.nval;
        for(int i = 1;i <= n;i++){
            re.nextToken();
            num[i] = (int)re.nval;
        }
        for(int i = 1;i <= n;i++){
            while(!q.isEmpty() && num[q.peekLast()] > num[i])
                q.removeLast();
            q.add(i);
            while(!q.isEmpty() && i - q.peekFirst() >= m)
                q.removeFirst();
            min[i] = num[q.peekFirst()];
        }
        for(int i = 0;i < n;i++)
            pr.println(min[i]);
        pr.flush();
    }
}

by zhy137036 @ 2020-04-06 15:22:22

您好,不能


by songxiao @ 2020-04-06 15:23:49

Java的好处都有啥?谁说对了就给他(滑稽


by FZzzz @ 2020-04-06 15:24:53

正常,国内OI题就没有考虑过其他的语言


by 珂朵莉! @ 2020-04-06 15:48:33

@Gorilla 可以写mc的mod


by _短笛无腔_ @ 2020-04-06 15:58:30

@Gorilla MC用了Java,伤害满,不被杀,零浪费


by _短笛无腔_ @ 2020-04-06 15:59:24

@Gorilla MC用了Java,可以无限刷砍手岩和砖石


by aminoas @ 2020-04-06 17:09:44

给阿姨倒一杯 Java, 给阿姨倒一杯 Java 好吧


by Yt_____ @ 2020-05-31 15:19:18

hhhhh。


by DOC_LingyunMoRRR @ 2020-07-05 09:42:57

@珂朵莉! mc粉实锤了


by DOC_LingyunMoRRR @ 2020-07-05 09:44:34

Java,还真的在国内混得不好,主要是Java在国内OI真的没什么前景


| 下一页