結果
| 問題 | No.1470 Mex Sum |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-05-24 03:58:24 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 992 bytes |
| 記録 | |
| コンパイル時間 | 1,540 ms |
| コンパイル使用メモリ | 219,840 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-05-24 03:58:30 |
| 合計ジャッジ時間 | 5,648 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | WA * 49 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) begin (x), end(x)
#define sz(x) (int) (x).size()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
mt19937 rng(random_device{}());
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vi a(n+1);
rep(i,1,n+1) cin >> a[i];
sort(a.begin(), a.end());
int mexSum = 0;
auto it_1 = upper_bound(a.begin()+1, a.end(), 1);
it_1--;
int qtd_1 = it_1 - a.begin();
auto it_2 = upper_bound(a.begin()+1, a.end(), 2);
it_2--;
int qtd_2 = it_2 - it_1;
int remainder = n - qtd_1 - qtd_2;
int comb = qtd_1 * qtd_2;
mexSum = 3*comb;
mexSum += 2 * qtd_1/2 * (qtd_1-1);
mexSum += qtd_2 * (qtd_2-1);
mexSum += remainder;
cout << mexSum;
}
vjudge1