結果

問題 No.2055 12x34...
ユーザー fact493fact493
提出日時 2022-08-21 13:13:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 7,750 bytes
コンパイル時間 4,749 ms
コンパイル使用メモリ 257,404 KB
実行使用メモリ 38,528 KB
最終ジャッジ日時 2024-10-10 06:03:09
合計ジャッジ時間 9,611 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
15,332 KB
testcase_01 AC 16 ms
15,180 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 141 ms
28,928 KB
testcase_13 AC 253 ms
37,524 KB
testcase_14 AC 89 ms
24,364 KB
testcase_15 AC 86 ms
24,616 KB
testcase_16 AC 257 ms
38,528 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef tuple<ll, ll, ll, ll> PPP;
using vvvvl = vector<vvvl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define lb(v, k) (lower_bound(all(v), (k)) - v.begin())
#define ub(v, k) (upper_bound(all(v), (k)) - v.begin())
#define eb emplace_back
#define fi first
#define se second
#define pq(T) priority_queue<T>
#define pqr(T) priority_queue<T, vector<T>, greater<T>>
#define pcount(i) __builtin_popcount(i);
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define all(a) (a).begin(), (a).end()
#define double long double
#define yesno(i) if(i)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define YesNo(i) if(i)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YESNO(i) if(i)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define cinvec(x)                     \
    for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \
    {                                 \
        cin >> x.at(hfuaig);               \
    }
#define coutvece(x)                   \
    for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \
    {                                 \
        cout << x.at(hfuaig) << endl;      \
    }
#define coutvec(x)                    \
    for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \
    {                                 \
        cout << x.at(hfuaig) << ' ';       \
    }
template <typename T>
bool chmax(T &a, const T& b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T& b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
const ll mod = 998244353;
const ll Mod = 1000000007;
const ll inf = 999999999999999999LL;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
ll gcd(ll A, ll B){
    if(A % B == 0){
        return B;
    }
    else{
        return gcd(B, A % B);
    }
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
long long modpow(long long a, long long n, long long mo) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mo;
        a = a * a % mo;
        n >>= 1;
    }
    return res;
}
//円の位置関係
bool isd(double a, double b, double c){
    if(c > (a + b) * (a + b)){
        return false;
    }
    if(c == (a + b) * (a + b)){
        return true;
    }
    if(abs(a - b) * abs(a - b) < c && c < (a + b) * (a + b)){
        return true;
    }
    if(c == abs(a - b) * abs(a - b)){
        return true;
    }
    if(c < abs(a - b) * abs(a - b)){
        return false;
    }
    return true;
}
const int MAX = 500000;
const int MOD = mod;
ll fact[MAX], inv_fact[MAX], inv[MAX];
void init() {
    // 初期値設定と1はじまりインデックスに直す
    fact[0] = 1;
    fact[1] = 1;
    inv[0] = 1;
    inv[1] = 1;
    inv_fact[0] = 1;
    inv_fact[1] = 1;
    // メモの計算
    repi(i, 2, MAX){
        // 階乗
        fact[i] = fact[i - 1] * i % MOD;
        // 逆元
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        // 逆元の階乗
        inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;
    }
}
ll nck(int n, int k) {
    ll x = fact[n]; // n!の計算
    ll y = inv_fact[n-k]; // (n-k)!の計算
    ll z = inv_fact[k]; // k!の計算
    if (n < k) return 0; // 例外処理
    if (n < 0 || k < 0) return 0; // 例外処理
    return x * ((y * z) % MOD) % MOD; //二項係数の計算
}
struct Edge {
    long long to;
    long long cost;
};
struct graph{
    vvp G;
    vl dis;
    vl prev;
    vl dijkstra(ll i){
        ll N = G.size();
        dis.assign(N, inf);
        prev.assign(N, -1);
        priority_queue<P, vector<P>, greater<P>> pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
        dis[i] = 0;
        pq.emplace(dis[i], i);
        while (!pq.empty()) {
            P p = pq.top();
            pq.pop();
            ll v = p.second;
            if (dis[v] < p.first) {  // 最短距離で無ければ無視
                continue;
            }
            for (auto &e : G[v]) {
                if (dis[e.fi] > dis[v] + e.se) {  // 最短距離候補なら priority_queue に追加
                    dis[e.fi] = dis[v] + e.se;
                    prev[e.fi] = v;
                    pq.emplace(dis[e.fi], e.fi);
                }
            }
        }
        return dis;
    }
    vl get_path(ll t){
        vl path;
        for (ll cur = t; cur != -1; cur = prev[cur]) {
            path.push_back(cur);
        }
        reverse(path.begin(), path.end()); // 逆順なのでひっくり返す
        return path;
    }
};
void beg(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(20);
    init();
    srand((unsigned int)time(NULL));
}

struct BIT {
  private:
   vector<int> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1, 0);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (int x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   ll sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
//転倒数ライブラリ
ll numfalls(vl &A){
    ll ans = 0;
    ll N = A.size();
    BIT b(N);
    rep(i, N){
        ans += i - b.sum(A.at(i));
        b.add(A.at(i), 1);
    }
    return ans;
}
//#define _GLIBCXX_DEBUG
#define mint998 modint998244353
#define mint107 modint1000000007
//約数列挙
vector<long long> div(long long n) {
    vector<long long> ret;
    set<ll> re;
    ll N = sqrt(n) + 1;
    for (long long i = 1; i <= N; i++) {
        if (n % i == 0) {
            re.insert(n / i);
            re.insert(i);
        }
    }
    for(auto value :re){
        ret.push_back(value);
    }
    return ret;
}
ll digit_sum(ll X){
    ll ans = 0;
    while(X > 0){
        ans += X%10;
        X/=10;
    }
    return ans;
}
void xypress(vl &A){
    vl B = A;
    sort(all(B));
    B.erase(unique(B.begin(), B.end()), B.end());
    vector<ll> res(A.size());
    for (int i = 0; i < A.size(); ++i) {
        res[i] = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
    }
    A = res;
}
//素数列挙
std::vector<ll> prime( const ll N )
{
    std::vector<bool> is_prime( N + 1 );
    for( ll i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<ll> P;
    for( ll i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( ll j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
//mod m での逆元
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//mod 998244353での割り算
ll inve(ll a, ll b){
    a %= mod;
    return (a * modinv(b, mod) % mod);
}
vl vecsum(vl x){
    vl s = {0};
    rep(i, x.size()){
        s.push_back(s.back() + x.at(i));
    }
    return s;
}
signed main()
{
    beg();
    ll N;
    cin >> N;
    vl A(N);
    cinvec(A);
    map<ll, ll> S, now;
    rep(i, N){
        S[A.at(i)]++;
        S[A.at(i)] += S[A.at(i) - 1];
    }
    ll ans = 0;
    for(auto x : S){
        ans += x.se;
    }
    ans -= N;
    cout << ans << endl;
}


  








0