結果
問題 |
No.831 都市めぐり
|
ユーザー |
|
提出日時 | 2021-01-29 22:11:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 1,845 ms |
コンパイル使用メモリ | 191,176 KB |
最終ジャッジ日時 | 2025-01-18 09:16:37 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) long long solve(int n) { long long ret = 0; for (int i = 0; i < (n + 1) / 2; i++) { long long x = i + 1; long long y = n + 1 - i; long long z = n - 1 - i; if (i == 0) --y; if (i + 1 == (n + 1) / 2) ++ z; if (x < y) ret += x * y; if (x < z) ret += x * z; } return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; cout << solve(n) << endl; return 0; }