Submission #69529681


Source Code Expand

#line 1 "/home/maomao90/Documents/IO/AtCoder/ARC206/A/A.cpp"

// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T> inline bool mnto(T &a, T b) { return b < a ? a = b, 1 : 0; }
template <class T> inline bool mxto(T &a, T b) { return a < b ? a = b, 1 : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int)_a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr                                                                   \
  if (0)                                                                       \
  cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 1000005;

int n;
int a[MAXN];
int cnt[MAXN], id[MAXN];

int main() {
#ifndef DEBUG
  ios::sync_with_stdio(0), cin.tie(0);
#endif
  cin >> n;
  REP (i, 1, n + 1) {
    cin >> a[i];
    id[i] = ++cnt[a[i]];
  }
  ll ans = 0;
  REP (i, 1, n + 1) {
    if (a[i] == a[i + 1]) {
      continue;
    }
    ans += n - i - (cnt[a[i]] - id[i]);
  }
  cout << ans + 1 << '\n';
  return 0;
}

Submission Info

Submission Time
Task A - Range Replace
User maomao90
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1669 Byte
Status AC
Exec Time 80 ms
Memory 15316 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 35
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_max_00.txt, 02_max_01.txt, 02_max_02.txt, 02_max_03.txt, 02_max_04.txt, 02_max_05.txt, 02_max_06.txt, 02_max_07.txt, 02_max_08.txt, 02_max_09.txt, 02_max_10.txt, 02_max_11.txt, 02_max_12.txt, 02_max_13.txt, 02_max_14.txt, 03_min_00.txt, 03_min_01.txt, 03_min_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3408 KiB
00_sample_01.txt AC 1 ms 3468 KiB
01_random_00.txt AC 25 ms 8112 KiB
01_random_01.txt AC 33 ms 9872 KiB
01_random_02.txt AC 34 ms 9776 KiB
01_random_03.txt AC 46 ms 12008 KiB
01_random_04.txt AC 51 ms 12840 KiB
01_random_05.txt AC 23 ms 7820 KiB
01_random_06.txt AC 25 ms 8296 KiB
01_random_07.txt AC 11 ms 5660 KiB
01_random_08.txt AC 8 ms 5080 KiB
01_random_09.txt AC 3 ms 4020 KiB
01_random_10.txt AC 56 ms 13836 KiB
01_random_11.txt AC 25 ms 8076 KiB
01_random_12.txt AC 5 ms 4580 KiB
01_random_13.txt AC 62 ms 14888 KiB
01_random_14.txt AC 5 ms 4616 KiB
02_max_00.txt AC 46 ms 15240 KiB
02_max_01.txt AC 30 ms 11336 KiB
02_max_02.txt AC 31 ms 11220 KiB
02_max_03.txt AC 53 ms 11288 KiB
02_max_04.txt AC 47 ms 11300 KiB
02_max_05.txt AC 49 ms 11256 KiB
02_max_06.txt AC 73 ms 15020 KiB
02_max_07.txt AC 74 ms 15176 KiB
02_max_08.txt AC 75 ms 15160 KiB
02_max_09.txt AC 80 ms 15184 KiB
02_max_10.txt AC 78 ms 15104 KiB
02_max_11.txt AC 77 ms 15316 KiB
02_max_12.txt AC 78 ms 15108 KiB
02_max_13.txt AC 79 ms 15040 KiB
02_max_14.txt AC 73 ms 15160 KiB
03_min_00.txt AC 1 ms 3476 KiB
03_min_01.txt AC 1 ms 3604 KiB
03_min_02.txt AC 1 ms 3420 KiB