提出 #19461838


ソースコード 拡げる

Copy
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  int64 ret = 0;
  for (int i = 0; i < m; ++i) {
    int j;
    for (j = 0; cnt[j]; ++j) --cnt[j];
    ret += j;
  }
  cout << ret << '\n';
  return 0;
}

提出情報

提出日時
問題 B - Mex Boxes
ユーザ cuiaoxiang
言語 C++ (Clang 10.0.0)
得点 400
コード長 2846 Byte
結果 AC
実行時間 165 ms
メモリ 4212 KB

コンパイルエラー

./Main.cpp:78:42: warning: unused variable 'inf' [-Wunused-const-variable]
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
                                         ^
./Main.cpp:79:11: warning: unused variable 'MOD' [-Wunused-const-variable]
const int MOD = 1e9 + 7;
          ^
2 warnings generated.

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 55
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 98 ms 4212 KB
hand_02.txt AC 92 ms 3788 KB
hand_03.txt AC 89 ms 3744 KB
hand_04.txt AC 92 ms 3816 KB
hand_05.txt AC 118 ms 3800 KB
hand_06.txt AC 118 ms 3688 KB
hand_07.txt AC 118 ms 3872 KB
hand_08.txt AC 118 ms 3816 KB
hand_09.txt AC 153 ms 3824 KB
hand_10.txt AC 152 ms 3788 KB
hand_11.txt AC 153 ms 3812 KB
hand_12.txt AC 158 ms 3768 KB
hand_13.txt AC 162 ms 3812 KB
hand_14.txt AC 141 ms 3696 KB
hand_15.txt AC 165 ms 3652 KB
hand_16.txt AC 140 ms 3704 KB
random_01.txt AC 74 ms 3260 KB
random_02.txt AC 64 ms 3240 KB
random_03.txt AC 109 ms 3552 KB
random_04.txt AC 100 ms 3500 KB
random_05.txt AC 70 ms 3268 KB
random_06.txt AC 66 ms 3344 KB
random_07.txt AC 103 ms 3536 KB
random_08.txt AC 95 ms 3240 KB
random_09.txt AC 62 ms 3164 KB
random_10.txt AC 62 ms 3344 KB
random_11.txt AC 99 ms 3532 KB
random_12.txt AC 74 ms 3120 KB
random_13.txt AC 52 ms 3264 KB
random_14.txt AC 102 ms 3532 KB
random_15.txt AC 95 ms 3568 KB
random_16.txt AC 67 ms 3400 KB
random_17.txt AC 90 ms 3380 KB
random_18.txt AC 97 ms 3516 KB
random_19.txt AC 59 ms 3116 KB
random_20.txt AC 62 ms 3100 KB
random_21.txt AC 84 ms 3236 KB
random_22.txt AC 76 ms 3280 KB
random_23.txt AC 61 ms 3396 KB
random_24.txt AC 108 ms 3384 KB
random_25.txt AC 75 ms 3548 KB
random_26.txt AC 62 ms 3284 KB
random_27.txt AC 55 ms 3116 KB
random_28.txt AC 100 ms 3552 KB
random_29.txt AC 65 ms 3260 KB
random_30.txt AC 54 ms 3244 KB
random_31.txt AC 52 ms 3268 KB
random_32.txt AC 107 ms 3556 KB
random_33.txt AC 74 ms 3528 KB
random_34.txt AC 69 ms 3352 KB
random_35.txt AC 57 ms 3216 KB
random_36.txt AC 98 ms 3548 KB
sample_01.txt AC 2 ms 3164 KB
sample_02.txt AC 2 ms 3136 KB
sample_03.txt AC 3 ms 3152 KB