結果
問題 |
No.2221 Set X
|
ユーザー |
|
提出日時 | 2023-02-17 22:33:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,115 bytes |
コンパイル時間 | 1,464 ms |
コンパイル使用メモリ | 168,648 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 13:46:11 |
合計ジャッジ時間 | 51,794 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ clock_t finish = clock() + CLOCKS_PER_SEC / 1000 * 1960; ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for(auto &&v:a)cin >> v; int pos = -1; int ans = 1 << 30; if(2 * n < ans){ ans = 2 * n; pos = 1; } if(a.back() + 2 < ans){ ans = a.back() + 2; pos = a.back() + 1; } vector<int> b(n); auto f = [&](int v){ int cnt = 1; for(int i = 0; i < n; i++){ b[i] = a[i] / v; if(i >= 1 && b[i] != b[i - 1])cnt++; } return cnt * (v + 1); }; for(int i = 1; i <= 320 && clock() <= finish; i++){ int v = f(i); if(v < ans){ ans = v; pos = i; } } for(int i = upper_bound(a.begin(), a.end(), 320) - a.begin(); i < n && clock() <= finish; i++){ int v = f(a[i] + 1); if(v < ans){ ans = v; pos = a[i] + 1; } } cout << pos << '\n'; cout << ans << '\n'; }