Submission #69846769
Source Code Expand
#include <bits/stdc++.h>
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
using ll = long long;
using db = double;
const ll N = 1e6 + 5;
const ll md = 998244353;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db eps = 1e-6;
const db E = 2.718281828459045;
typedef pair<ll, ll> PLL;
#define fi first
#define se second
void solve()
{
ll n, q, x, y;
cin >> n >> q;
map<ll, ll> mp;
for (ll i = 1; i <= n; i++)
mp[i]++;
ll z = 0;
for (ll i = 1; i <= q; i++)
{
cin >> x >> y;
ll res = 0;
for (ll j = z + 1; j <= x; j++)
{
res += mp[j];
mp[j] = 0;
}
if (x > z)
z = x;
mp[y] += res;
cout << res << '\n';
}
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T;
T = 1;
// cin>>T;
while (T--)
{
solve();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Upgrade Required |
| User | AChievedreaM |
| Language | C++ 20 (gcc 12.2) |
| Score | 300 |
| Code Size | 1020 Byte |
| Status | AC |
| Exec Time | 618 ms |
| Memory | 66104 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt |
| All | hand_01.txt, hand_02.txt, hand_03.txt, sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hand_01.txt | AC | 311 ms | 65888 KiB |
| hand_02.txt | AC | 380 ms | 65940 KiB |
| hand_03.txt | AC | 387 ms | 65976 KiB |
| sample_01.txt | AC | 1 ms | 3532 KiB |
| test_01.txt | AC | 1 ms | 3396 KiB |
| test_02.txt | AC | 609 ms | 65972 KiB |
| test_03.txt | AC | 614 ms | 65976 KiB |
| test_04.txt | AC | 618 ms | 66100 KiB |
| test_05.txt | AC | 322 ms | 65964 KiB |
| test_06.txt | AC | 558 ms | 65968 KiB |
| test_07.txt | AC | 305 ms | 66024 KiB |
| test_08.txt | AC | 514 ms | 65896 KiB |
| test_09.txt | AC | 513 ms | 66028 KiB |
| test_10.txt | AC | 25 ms | 3484 KiB |
| test_11.txt | AC | 25 ms | 3484 KiB |
| test_12.txt | AC | 24 ms | 3424 KiB |
| test_13.txt | AC | 25 ms | 3508 KiB |
| test_14.txt | AC | 565 ms | 66100 KiB |
| test_15.txt | AC | 336 ms | 65988 KiB |
| test_16.txt | AC | 600 ms | 65960 KiB |
| test_17.txt | AC | 572 ms | 65944 KiB |
| test_18.txt | AC | 335 ms | 65828 KiB |
| test_19.txt | AC | 598 ms | 66104 KiB |
| test_20.txt | AC | 515 ms | 65888 KiB |
| test_21.txt | AC | 513 ms | 66036 KiB |
| test_22.txt | AC | 512 ms | 65964 KiB |