結果
問題 | No.831 都市めぐり |
ユーザー |
|
提出日時 | 2019-05-24 21:41:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 151 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 569 ms |
コンパイル使用メモリ | 67,904 KB |
実行使用メモリ | 65,920 KB |
最終ジャッジ日時 | 2024-09-17 10:30:46 |
合計ジャッジ時間 | 1,906 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include<iostream>#include<list>using namespace std;typedef long long ll;int main(){int n;cin >> n;if(n==1){cout << 0 << endl;return 0;}ll ans = 0;list<ll> l;int low = 1, high = n;l.push_back(high--);while(low <= high){if(low <= high) l.push_front(low++);if(low <= high) l.push_back(low++);if(low <= high) l.push_front(high--);if(low <= high) l.push_back(high--);}auto it = l.begin();while(it != l.end()){auto nit = it;nit++;if(nit == l.end()) nit = l.begin();ans += (*it) * (*nit);it++;}cout << ans << endl;return 0;}