結果
| 問題 | No.1470 Mex Sum |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-05-24 04:13:43 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,012 bytes |
| 記録 | |
| コンパイル時間 | 1,396 ms |
| コンパイル使用メモリ | 220,080 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-05-24 04:13:47 |
| 合計ジャッジ時間 | 3,367 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 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 += qtd_1/2 * (qtd_1-1);
mexSum += (qtd_2 * (qtd_2-1))/2;
mexSum += (remainder * (remainder-1))/2;
cout << mexSum;
}
vjudge1