提出 #69865435
ソースコード 拡げる
// PriashisG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// Typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;
/*
greater<int> for large to small
less_equal for not unique
finding sz-th element --> os.find_by_order(sz); // O(log n)
finding the number of elements smaller than x --> os.order_by_szey(x); // O(log n)
os.erase(x);
*/
// Macros
#define PB push_back
#define IN insert
#define all(x) x.begin(), x.end()
#define trav(i, a) for (auto &i : a)
#define GCD __gcd
#define F first
#define S second
#define endl '\n'
#define LB lower_bound
#define UB upper_bound
#define DEBUG(i) cout << "DEBUG " << i << "\n";
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define GT(x) greater<x>()
#define setpre(n) fixed << setprecision(n)
#define SZ(x) x.size()
// Functions
template <typename T> void pv(vector<T> &a){
for (T u : a) cout << u << ' ';
cout << '\n';
}
template <typename T> void pv2(vector<vector<T>> &a){
trav(aa, a) pv(aa);
}
template <typename T, typename U> void pvp( vector<pair<T, U>> &a){
trav(p, a) cout << "(" << p.F << ", " << p.S << ") ";
cout << '\n';
}
// Constants
const ll MOD7 = 1e9 + 7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
// Custom Functions
void fast(){
ios::sync_with_stdio(false); cin.tie(0);
}
ll LCM(ll a, ll b){
return (a * b) / GCD(a, b);
}
// Custom Comparator
bool cmp(const pair<ll, ll>& x, const pair<ll, ll>& y){
if (x.F == y.F) return x.S > y.S;
else return x.F < y.F;
}
// Global Variables
void solve(ll tc){
int n, q;
cin >> n >> q;
map<ll, ll> cnt;
for (int i = 1; i <= n; i++) cnt[i] = 1;
while (q--) {
int x, y;
cin >> x >> y;
auto it = cnt.begin();
ll ans = 0;
while (it != cnt.end() && it->F <= x){
ans += it->S;
it = cnt.erase(it);
}
cnt[y] += ans;
cout << ans << '\n';
}
}
int main(void){
fast();
// precal();
// freopen("fenceplan.in", "r", stdin);
// freopen("fenceplan.out", "w", stdout);
ll t = 1;
int i = 1;
// cin >> t;
// for (ll i = 1; i <= t; i++)
solve(i);
}
提出情報
コンパイルエラー
Main.cpp: In function ‘void solve(ll)’:
Main.cpp:82:15: warning: unused parameter ‘tc’ [-Wunused-parameter]
82 | void solve(ll tc){
| ~~~^~
Main.cpp: In function ‘int main()’:
Main.cpp:118:8: warning: unused variable ‘t’ [-Wunused-variable]
118 | ll t = 1;
| ^
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
300 / 300 |
| 結果 |
|
|
| セット名 |
テストケース |
| 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 |
| ケース名 |
結果 |
実行時間 |
メモリ |
| hand_01.txt |
AC |
271 ms |
66152 KiB |
| hand_02.txt |
AC |
270 ms |
65948 KiB |
| hand_03.txt |
AC |
279 ms |
66036 KiB |
| sample_01.txt |
AC |
1 ms |
3536 KiB |
| test_01.txt |
AC |
1 ms |
3500 KiB |
| test_02.txt |
AC |
273 ms |
65920 KiB |
| test_03.txt |
AC |
271 ms |
66016 KiB |
| test_04.txt |
AC |
272 ms |
66032 KiB |
| test_05.txt |
AC |
279 ms |
66012 KiB |
| test_06.txt |
AC |
278 ms |
66028 KiB |
| test_07.txt |
AC |
260 ms |
66028 KiB |
| test_08.txt |
AC |
260 ms |
65964 KiB |
| test_09.txt |
AC |
264 ms |
65952 KiB |
| test_10.txt |
AC |
25 ms |
3508 KiB |
| test_11.txt |
AC |
25 ms |
3492 KiB |
| test_12.txt |
AC |
25 ms |
3572 KiB |
| test_13.txt |
AC |
25 ms |
3568 KiB |
| test_14.txt |
AC |
288 ms |
65928 KiB |
| test_15.txt |
AC |
276 ms |
65980 KiB |
| test_16.txt |
AC |
278 ms |
65884 KiB |
| test_17.txt |
AC |
286 ms |
65956 KiB |
| test_18.txt |
AC |
277 ms |
66104 KiB |
| test_19.txt |
AC |
279 ms |
65964 KiB |
| test_20.txt |
AC |
270 ms |
66016 KiB |
| test_21.txt |
AC |
272 ms |
66028 KiB |
| test_22.txt |
AC |
274 ms |
66032 KiB |