結果
問題 |
No.568 じゃんじゃん 落とす 委員会
|
ユーザー |
|
提出日時 | 2025-05-17 17:48:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,102 bytes |
コンパイル時間 | 2,636 ms |
コンパイル使用メモリ | 198,644 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-17 17:48:30 |
合計ジャッジ時間 | 6,180 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 26 |
コンパイルメッセージ
main.cpp: In member function ‘int BIT::add(int, int)’: main.cpp:52:9: warning: no return statement in function returning non-void [-Wreturn-type] 52 | } | ^
ソースコード
#include<bits/stdc++.h> #define lowbit(x) x & (-x) #define ls(k) k << 1 #define rs(k) k << 1 | 1 #define fi first #define se second #define ctz(x) __builtin_ctz(x) #define popcnt(x) __builtin_popcount(x) #define open(s1, s2) freopen(s1, "r", stdin), freopen(s2, "w", stdout); using namespace std; typedef __int128 __; typedef long double lb; typedef double db; typedef unsigned long long ull; typedef long long ll; bool Begin; const int N = 1e5 + 10; inline ll read(){ ll x = 0, f = 1; char c = getchar(); while(c < '0' || c > '9'){ if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void write(ll x){ if(x < 0){ putchar('-'); x = -x; } if(x > 9) write(x / 10); putchar(x % 10 + '0'); } int n, m, now, ans, sum = 1e9; vector<pair<int, int>> V[N]; class BIT{ public: int all = 0; int a[N]; inline int add(int x, int v){ all += v; ++x; for(int i = x; i < N; i += lowbit(i)) a[i] += v; } inline int ask(int x){ int sum = 0; for(int i = x; i; i -= lowbit(i)) sum += a[i]; return all - sum; } }T1, T2; bool End; int main(){ n = read(), m = read(); for(int x, a, b, i = 1; i <= n; ++i){ x = read(), a = read(), b = read(); if(x >= 1) ++now; if(x >= 2) ++ans; if(x == 1) T1.add(b, 1); if(!x) T2.add(b, 1); V[a].push_back({x, b}); } if(now >= m) sum = min(sum, ans); for(int i = 0; i <= 1e5; ++i){ for(auto v : V[i]){ int x = v.fi, b = v.se; if(x >= 3) continue; if(x == 2){ --ans; T1.add(b, 1); } if(x == 1){ --now; T2.add(b, 1); T1.add(b, -1); } if(!x) T2.add(b, -1); } if(now >= m) sum = min(sum, ans); int l = 0, r = 1e5, sb = -1; while(l <= r){ int mid = (l + r) >> 1; if(T2.ask(mid) + now >= m){ sb = mid; l = mid + 1; } else r = mid - 1; } if(sb != -1) sum = min(sum, ans + T1.ask(sb)); } write(sum); cerr << '\n' << abs(&Begin - &End) / 1048576 << "MB"; return 0; }