結果
問題 |
No.2221 Set X
|
ユーザー |
![]() |
提出日時 | 2024-01-15 02:19:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 362 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 4,813 ms |
コンパイル使用メモリ | 193,836 KB |
最終ジャッジ日時 | 2025-02-18 20:09:37 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for( int i = 0; i < N; i++ ) { cin >> A[i]; } vector<int> f(2*N); for( int x = 1; x <= 2*N; x++ ) { int cnt = 0, pos = 0; while( (x+1)*cnt <= 2*N && pos < N ) { int ok = pos, ng = N; while( ok+1 < ng ) { int k = (ok+ng)/2; if( A[pos]/x == A[k]/x ) ok = k; else ng = k; } cnt++; pos = ok+1; } f[x-1] = (x+1)*cnt; } auto itr = min_element(f.begin(), f.end()); cout << itr-f.begin()+1 << "\n" << *itr << endl; }