結果
問題 | No.2221 Set X |
ユーザー |
![]() |
提出日時 | 2023-02-17 23:18:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 807 bytes |
コンパイル時間 | 1,862 ms |
コンパイル使用メモリ | 200,300 KB |
最終ジャッジ日時 | 2025-02-10 18:07:41 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 5 TLE * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for (long long i=0;i<(long long)(n);i++) #define all(v) v.begin(),v.end() using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; const ll INF=(1ll<<60); template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } ll n; vector<ll> a; ll f(ll x){ set<ll> st; rep(i,n) st.insert(a[i]/x); return (x+1)*st.size(); } int main(){ cin >> n; a.resize(n); rep(i,n) cin >> a[i]; pll ans={INF,f(a.back()+1)}; rep(i,1000){ chmin(ans,{f(i+1),i+1}); } rep(i,min(n,1000ll)){ if(a[i]==0) continue; chmin(ans,{f(a[i]),a[i]}); } cout << ans.second << endl; cout << ans.first << endl; }