結果

問題 No.607 開通777年記念
ユーザー iiljjiiljj
提出日時 2021-01-14 20:42:47
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,332 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 31,488 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-05-03 13:41:37
合計ジャッジ時間 889 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 11 ms
9,984 KB
testcase_12 AC 9 ms
9,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>

// clang-format off
#define RD(v) int v=0;{int _c,sign=0;for(;;){if(*rp=='-'){sign=1;rp++;}else{_c=*rp++-48;if(_c>=0)v=v*10+_c;else break;}}if(sign)v=-v;} //
// clang-format on

int a[1000 * 1000];
int b[1001];
#define TARGET 777
int main() {
    char *rp = (char *)mmap(0l, 1l << 28, 1, 2, 0, 0ll);
    RD(n) RD(m);
    int *rap = a;
    int *nm = rap + n * m;
    while (rap < nm) {
        RD(t);
        *rap++ = t;
    }

    // b[n] = 1000000000 + 9;
    int *ap = a;
    while (ap < rap) {
        int *bp = b;
        while (bp - b < n) *bp++ += *ap++;
        // for (int j = 0; j < n; ++j) printf("%d ", b[j]);
        // printf("\n");

        int *left = b;
        int sm = 0;
        for (int *right = b; right < bp; ++right) {
            sm += *right;
            if (sm == TARGET) {
                printf("YES");
                exit(0);
            } else if (sm > TARGET) {
                do {
                    sm -= *left;
                    left++;
                } while (sm > TARGET);
                if (sm == TARGET) {
                    printf("YES");
                    exit(0);
                }
            }
        }
    }
    printf("NO");
    exit(0);
    return 0; //
}
0