結果

問題 No.607 開通777年記念
ユーザー iiljjiiljj
提出日時 2021-01-14 20:18:32
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,641 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 32,740 KB
実行使用メモリ 10,032 KB
最終ジャッジ日時 2024-05-03 13:14:52
合計ジャッジ時間 1,632 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 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 WA -
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 10 ms
10,032 KB
testcase_12 AC 9 ms
9,496 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;} //
#define RDULL(v) unsigned long long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} //
#define wt_int(var,buf,ptr) while(var){buf[ptr++]=var%10;var/=10;}while(ptr--)putc_unlocked(buf[ptr]+'0',stdout);
// 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 *ap = a;
    int nm = n * m;
    for (int i = 0; i < nm; ++i) {
        RD(t);
        *ap++ = t;
    }

    // b[n] = 1000000000 + 9;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) b[j] += a[n * i + j];
        // for (int j = 0; j < n; ++j) printf("%d ", b[j]);
        // printf("\n");

        int left = 0;
        int sm = 0;
        for (int right = 0; right < n; ++right) {
            int s = sm + b[right];
            // printf("%d %d %d = %d + %d\n", i, right, s, sm, b[right]);
            if (s >= TARGET) {
                if (s == TARGET) {
                    printf("YES");
                    exit(0);
                }
                if (right == n) break;
                while (sm + b[right] > TARGET) {
                    sm -= b[left];
                    left++;
                }
                sm += b[right];
            } else {
                sm += b[right];
            }
        }
    }
    printf("NO");
    exit(0);
    return 0; //
}
0