結果

問題 No.2880 Max Sigma Mod
コンテスト
ユーザー t98slider
提出日時 2024-09-08 13:00:35
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 440 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,004 ms
コンパイル使用メモリ 211,292 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2026-07-05 15:05:58
合計ジャッジ時間 3,693 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
In function 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]',
    inlined from 'int main()' at main.cpp:16:16:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_algobase.h:263:7: warning: 'l' is used uninitialized [-Wuninitialized]
  263 |       if (__a < __b)
      |       ^~
main.cpp: In function 'int main()':
main.cpp:16:9: note: 'l' was declared here
   16 |     int l = max(l, m - 50);
      |         ^

ソースコード

diff #
raw source code

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    auto f = [&](int x){
        ll res = 0;
        for(int i = 2; i <= m; i++) res += x % i;
        return res;
    };
    ll ans = f(n);
    int l = max(l, m - 50);
    int r = min(n, m + 50);
    for(int i = l; i <= r; i++) ans = max(ans, f(i));
    cout << ans << '\n';
}
0