結果
| 問題 |
No.2221 Set X
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-09 18:22:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,858 ms / 2,000 ms |
| コード長 | 699 bytes |
| コンパイル時間 | 1,490 ms |
| コンパイル使用メモリ | 163,136 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-02-09 18:22:50 |
| 合計ジャッジ時間 | 23,859 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
long long tim=0;
void sol() {
int n; cin>>n;
vector<int> a(n);
for(int &x:a)
cin>>x;
using pii = pair<long long,int>;
pii ans={2*n,1};
for(int i=2;i<2*n&&i<=a[n-1]+1;i++) {
long long sum=0;
auto it=a.begin();
do {
sum++;
it=lower_bound(it,a.end(),((*it)/i+1)*i);
} while(it!=a.end());
ans=min(ans,pii{sum*(i+1),i});
if(((double)clock()-tim)/CLOCKS_PER_SEC>1.8) break;
}
cout<<ans.second<<'\n'<<ans.first<<'\n';
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int T=1;
while(T--)
sol();
return 0;
}