提出 #60363536


ソースコード 拡げる

#include <bits/stdc++.h>
#include <atcoder/all>

#define all(x) (x).begin(), (x).end()
#define fix(x) fixed << setprecision(x)
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
#define rrep(i, start, end) for (auto i = (start); (i) >= (end); (i)--)

constexpr auto PI = 3.14159265358979;
constexpr auto INF = 1e+9;
constexpr auto INFL = 1LL << 60;

using namespace std;
using namespace atcoder;
using ll = long long;
using lld = long double;
// using mint = modint1000000007;
using mint = modint998244353;
using Pair_int = pair<int, int>;
using Pair_ll = pair<ll, ll>;
template <class T>
using Graph = vector<vector<T>>;

template <class T1, class T2>
inline auto div_floor(T1 a, T2 b)
{
    if (b < 0)
        a *= -1, b *= -1;
    if (a >= 0)
        return a / b;
    else
        return (a + 1) / b - 1;
}
template <class T1, class T2>
inline auto div_ceil(T1 a, T2 b)
{
    if (b < 0)
        a *= -1, b *= -1;
    if (a <= 0)
        return a / b;
    else
        return (a - 1) / b + 1;
}
ll pow(ll x, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}
ll pow_mod(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll gcd(ll x, ll y)
{
    if (x < y)
        swap(x, y);
    ll r;
    while (y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
ll lcm(ll x, ll y) { return ll(x / gcd(x, y)) * y; }
ll nCk(ll n, ll r)
{
    if (r < 0 || n < r)
        return 0;
    ll ans = 1;
    for (ll i = 1; i <= r; i++)
    {
        ans *= n--;
        ans /= i;
    }
    return ans;
}
int get_rand(int seed, int min, int max)
{
    static mt19937_64 mt64(seed);
    uniform_int_distribution<int> get_rand_int(min, max);
    return get_rand_int(mt64);
}
template <typename T>
inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T>
inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
template <class T1, class T2>
inline auto mod(T1 x, T2 r) { return (x % r + r) % r; }

// ======================================== //

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, M) cin >> B[i];

    const int MAX = 202020;
    vector<int> p_min(MAX, INF);
    rep(i, 0, N) p_min[A[i]] = min(p_min[A[i]], i + 1);
    rep(i, 0, MAX) p_min[i + 1] = min(p_min[i + 1], p_min[i]);

    rep(j, 0, M)
    {
        if (p_min[B[j]] == INF)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << p_min[B[j]] << endl;
        }
    }

    return 0;
}

提出情報

提出日時
問題 C - Kaiten Sushi
ユーザ Yuulis
言語 C++ 23 (gcc 12.2)
得点 350
コード長 2780 Byte
結果 AC
実行時間 254 ms
メモリ 5644 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 350 / 350
結果
AC × 3
AC × 30
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3996 KiB
00_sample_01.txt AC 1 ms 4000 KiB
00_sample_02.txt AC 1 ms 3892 KiB
01_random_00.txt AC 106 ms 4432 KiB
01_random_01.txt AC 46 ms 4320 KiB
01_random_02.txt AC 196 ms 5032 KiB
01_random_03.txt AC 206 ms 5212 KiB
01_random_04.txt AC 117 ms 4772 KiB
02_random2_00.txt AC 249 ms 5584 KiB
02_random2_01.txt AC 253 ms 5552 KiB
02_random2_02.txt AC 252 ms 5556 KiB
02_random2_03.txt AC 254 ms 5492 KiB
02_random2_04.txt AC 252 ms 5560 KiB
02_random2_05.txt AC 252 ms 5568 KiB
02_random2_06.txt AC 253 ms 5584 KiB
02_random2_07.txt AC 252 ms 5540 KiB
02_random2_08.txt AC 252 ms 5564 KiB
02_random2_09.txt AC 252 ms 5612 KiB
02_random2_10.txt AC 252 ms 5548 KiB
02_random2_11.txt AC 251 ms 5568 KiB
02_random2_12.txt AC 252 ms 5488 KiB
02_random2_13.txt AC 253 ms 5584 KiB
02_random2_14.txt AC 251 ms 5640 KiB
02_random2_15.txt AC 252 ms 5580 KiB
02_random2_16.txt AC 250 ms 5556 KiB
03_handmade_00.txt AC 247 ms 5640 KiB
03_handmade_01.txt AC 245 ms 5644 KiB
03_handmade_02.txt AC 216 ms 4792 KiB
03_handmade_03.txt AC 215 ms 4768 KiB
03_handmade_04.txt AC 1 ms 4004 KiB