結果

問題 No.607 開通777年記念
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-07 00:08:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 642 ms / 2,000 ms
コード長 2,010 bytes
コンパイル時間 3,171 ms
コンパイル使用メモリ 77,768 KB
実行使用メモリ 46,308 KB
最終ジャッジ日時 2024-05-06 17:20:44
合計ジャッジ時間 5,496 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
37,228 KB
testcase_01 AC 44 ms
36,988 KB
testcase_02 AC 45 ms
37,140 KB
testcase_03 AC 44 ms
37,008 KB
testcase_04 AC 45 ms
36,972 KB
testcase_05 AC 45 ms
36,944 KB
testcase_06 AC 44 ms
36,988 KB
testcase_07 AC 215 ms
45,336 KB
testcase_08 AC 45 ms
36,928 KB
testcase_09 AC 110 ms
40,912 KB
testcase_10 AC 110 ms
40,508 KB
testcase_11 AC 642 ms
46,308 KB
testcase_12 AC 588 ms
46,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        long[]ans=new long[n];
        boolean ok=false;
        for(int i=0;i<m;++i){
            for(int j=0;j<n;++j)
                ans[j]+=sc.nextInt();
            Set<Long>hm=new HashSet<Long>();
            long c=0;
            for(int j=0;j<n;++j){
                hm.add(c);
                c+=ans[j];
                if(hm.contains(c-777)){
                    ok=true;
                    break;
                }
            }
        }
        out.println(ok?"YES":"NO");
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
0