結果

問題 No.1256 連続整数列
ユーザー れいん
提出日時 2024-11-29 11:25:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 2,549 ms
コンパイル使用メモリ 245,496 KB
実行使用メモリ 11,240 KB
最終ジャッジ日時 2024-11-29 11:26:00
合計ジャッジ時間 4,351 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int A;
    cin >> A;
    vector<long long> sum(1e6 + 1);
    for (int i = 1; i <= 1e6; i++)
    {
        sum[i] = sum[i - 1] + i;
    }
    for (int i = 1; i <= 1e6; i++)
    {
        long long search = sum[i] - A;
        auto it = lower_bound(sum.begin(), sum.end(), search);
        if (it == sum.end())
        {
            continue;
        }
        if (*it == search)
        {
            int a = it - sum.begin();
            if (i - (it - sum.begin()) >= 3)
            {
                cout << "YES";
                return 0;
            }
        }
    }
    cout << "NO";
}
0