結果

問題 No.3048 Swing
ユーザー suisen
提出日時 2025-01-18 15:43:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 367 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 79,572 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2025-01-18 15:43:58
合計ジャッジ時間 41,206 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 53 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

// TLE

#include <cassert>
#include <cmath>
#include <iostream>

long long solve(const long long x, const long long n) {
    long long ans = x;
    for (long long i = 1; i <= n; ++i) {
        if (ans <= 0) ans += i;
        else ans -= i;
    }
    return ans;
}

int main() {
    long long x, n;
    std::cin >> x >> n;
    std::cout << solve(x, n) << std::endl;
}
0