Submission #76067908


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main()
{
    ll N, Q;
    cin >> N >> Q;

    vector<ll> height(N, 0);

    // num[i] = 実高さが i+1 以上のマス数
    vector<ll> num(Q + 10, 0);

    ll kijun = 0;

    for (ll i = 0; i < Q; i++)
    {
        ll q;
        cin >> q;
        if (q == 1)
        {
            ll x;
            cin >> x;
            x--;
            height[x]++;
            num[height[x] - 1]++;
            while (kijun < Q && num[kijun] == N)
            {
                kijun++;
            }
        }
        else
        {
            ll y;
            cin >> y;
            y--;
            ll idx = y + kijun - 1;

            if (y + kijun > Q)
            {
                cout << 0 << endl;
            }
            else
            {
                cout << num[y + kijun] << endl;
            }
        }
    }

    return 0;
}

// #include <bits/stdc++.h>
// using namespace std;
// #define ll long long
// #define LONGMAX 1e18
// #define INTMAX 2147483647

// int main(void)
// {
//     ll N, Q;
//     cin >> N >> Q;
//     vector<ll> height(N, 0);
//     vector<ll> num(Q + 10, 0);
//     ll kijun = 0;
//     for (int i = 0; i < Q; i++)
//     {
//         ll q;
//         cin >> q;
//         if (q == 1)
//         {
//             ll x;
//             cin >> x;
//             x--;
//             height[x]++;
//             num[height[x] - kijun - 1]++;
//             if (num[height[x] - kijun - 1] == N)
//             {
//                 kijun++;
//             }
//             // for (int j = 0; j < N; j++)
//             // {
//             //     cout << height[j] << " ";
//             // }
//             // cout << endl;
//             // for (int j = 0; j < Q; j++)
//             // {
//             //     cout << num[j] << " ";
//             // }
//             // cout << endl;
//             // cout << kijun << endl;
//         }
//         else
//         {
//             ll y;
//             cin >> y;
//             y--;
//             cout << num[y + kijun] << endl;
//         }
//     }
//     return 0;
// }

Submission Info

Submission Time
Task C - Drop Blocks
User lalashvbp
Language C++23 (GCC 15.2.0)
Score 300
Code Size 2235 Byte
Status AC
Exec Time 178 ms
Memory 7908 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:39:16: warning: unused variable 'idx' [-Wunused-variable]
   39 |             ll idx = y + kijun - 1;
      |                ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 50
Set Name Test Cases
Sample example_00.txt
All example_00.txt, hand_00.txt, 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, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, hand_24.txt, hand_25.txt, hand_26.txt, hand_27.txt, hand_28.txt, random_00.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
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3464 KiB
hand_00.txt AC 76 ms 7808 KiB
hand_01.txt AC 75 ms 7908 KiB
hand_02.txt AC 175 ms 5552 KiB
hand_03.txt AC 149 ms 5540 KiB
hand_04.txt AC 114 ms 6748 KiB
hand_05.txt AC 111 ms 5592 KiB
hand_06.txt AC 108 ms 5560 KiB
hand_07.txt AC 48 ms 5608 KiB
hand_08.txt AC 150 ms 5560 KiB
hand_09.txt AC 99 ms 5604 KiB
hand_10.txt AC 101 ms 5652 KiB
hand_11.txt AC 63 ms 5516 KiB
hand_12.txt AC 64 ms 5540 KiB
hand_13.txt AC 166 ms 5608 KiB
hand_14.txt AC 121 ms 5552 KiB
hand_15.txt AC 119 ms 5604 KiB
hand_16.txt AC 1 ms 3392 KiB
hand_17.txt AC 178 ms 7856 KiB
hand_18.txt AC 47 ms 5560 KiB
hand_19.txt AC 47 ms 5604 KiB
hand_20.txt AC 47 ms 5536 KiB
hand_21.txt AC 115 ms 7908 KiB
hand_22.txt AC 74 ms 7780 KiB
hand_23.txt AC 152 ms 7900 KiB
hand_24.txt AC 146 ms 7900 KiB
hand_25.txt AC 2 ms 5600 KiB
hand_26.txt AC 2 ms 5576 KiB
hand_27.txt AC 13 ms 5644 KiB
hand_28.txt AC 89 ms 5604 KiB
random_00.txt AC 103 ms 5552 KiB
random_01.txt AC 116 ms 5652 KiB
random_02.txt AC 114 ms 5592 KiB
random_03.txt AC 131 ms 5604 KiB
random_04.txt AC 145 ms 5540 KiB
random_05.txt AC 120 ms 5592 KiB
random_06.txt AC 78 ms 5504 KiB
random_07.txt AC 145 ms 5564 KiB
random_08.txt AC 97 ms 5504 KiB
random_09.txt AC 103 ms 5680 KiB
random_10.txt AC 126 ms 5476 KiB
random_11.txt AC 81 ms 5504 KiB
random_12.txt AC 155 ms 5608 KiB
random_13.txt AC 119 ms 5552 KiB
random_14.txt AC 105 ms 5720 KiB
random_15.txt AC 72 ms 5560 KiB
random_16.txt AC 136 ms 5540 KiB
random_17.txt AC 87 ms 5516 KiB
random_18.txt AC 116 ms 5600 KiB
random_19.txt AC 107 ms 5644 KiB