結果
| 問題 |
No.2221 Set X
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-02-17 22:40:06 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,400 bytes |
| コンパイル時間 | 3,955 ms |
| コンパイル使用メモリ | 278,060 KB |
| 実行使用メモリ | 228,348 KB |
| 最終ジャッジ日時 | 2024-07-19 13:51:39 |
| 合計ジャッジ時間 | 11,116 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 TLE * 1 -- * 21 |
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> r[10000000];
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
set<int> xl;
unordered_map<int,int> sashi;
unordered_map<int,int> ars;
int cnt = 0;
int x = 0;
vector<int> a(n);
vector<int> b(n);
int am = 0;
ll setnum = 0;
for (int i=0; i<n; i++){
int x; cin >> x;
b[i] = x;
if (ars[0] == 0) setnum++;
ars[0]++;
am = max(am, x);
if (x > 0){
if (xl.find(x) == xl.end()){
sashi[x] = cnt;
r[cnt].push_back(i);
cnt++;
xl.insert(x);
}else{
r[sashi[x]].push_back(i);
}
}
}
ll ans = (ll)am + 2;
int ansx = am + 1;
while (!xl.empty()){
auto xind = xl.end();
xind--;
int x = *xind;
xl.erase(xind);
for (int j: r[sashi[x]]){
ars[a[j]]--;
if (ars[a[j]] == 0){
setnum--;
}
a[j] = b[j] / x;
if (ars[a[j]] == 0){
setnum++;
}
ars[a[j]]++;
int targ = b[j] / (a[j] + 1);
if (targ > 0){
if (xl.find(targ) == xl.end()){
sashi[targ] = cnt;
r[cnt].push_back(j);
cnt++;
xl.insert(targ);
}else{
r[sashi[targ]].push_back(j);
}
}
}
if (ans >= setnum * (x + 1)){
ans = setnum * (x + 1);
ansx = x;
}
}
cout << ansx << endl;
cout << ans << endl;
}
shobonvip