QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686882 | #6416. Classical Scheduling Problem | badminton | WA | 1ms | 5704kb | C++14 | 3.3kb | 2024-10-29 16:15:25 | 2024-10-29 16:15:26 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <ll,ll> pii;
typedef pair <pii,ll> piii;
#define forr(_a,_b,_c) for(ll _a = (_b); _a <= ll (_c); ++_a)
#define ford(_a,_b,_c) for(ll _a = (_b) + 1; _a --> ll (_c);)
#define forf(_a,_b,_c) for(ll _a = (_b); _a < ll (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"
template<class X, class Y>
bool minz(X &x, const Y &y) {
if (x > y) {
x = y;
return true;
} return false;
}
template<class X, class Y>
bool maxz(X &x, const Y &y) {
if (x < y) {
x = y;
return true;
} return false;
}
const ll N = 5e5 + 5;
const ll oo = (ll) 1e16;
const ll mod = 1e9 + 7; // 998244353;
piii a[N];
ll n, t;
priority_queue<pii> q;
ll suf[N];
ll check(ll k){
if (!k) return 1;
while (!q.empty()){
q.pop();
}
ll sum = 0;
ford (i, n, 1){
if (i < n){
q.push({a[i + 1].st.nd, i});
sum = sum + a[i + 1].st.nd;
}
ll need = max (a[i].st.nd - k, 0ll);
if (need > q.size()){
suf[i] = 1e15;
continue;
}
while (need < q.size()){
sum = sum - q.top().st;
q.pop();
}
suf[i] = sum;
}
while (!q.empty()){
q.pop();
}
ll now = 1;
ll pref = 0;
for (ll i = k; i <= n; i++){
while (now < i){
q.push({a[now].st.nd, now});
pref = pref + a[now].st.nd;
now++;
}
while (q.size() > k - 1){
pref = pref - q.top().st;
q.pop();
}
if (pref + suf[i] + a[i].st.nd <= t){
return i;
}
}
return 0;
}
bool cmp(piii x, piii y){
return x.st.nd < y.st.nd;
}
void getans(ll k, ll p){
cout << k << "\n";
if (k == 0){
cout << "0\n";
return;
}
vector<ll> ans;
while (!q.empty()){
ans.pb(a[q.top().nd].nd);
q.pop();
}
ans.pb(a[p].nd);
sort(a + 1 + p, a + 1 + n, cmp);
forr (i, p + 1, p + a[p].st.nd - k){
ans.pb(a[i].nd);
}
sort(all(ans));
cout << ans.size() << "\n";
for (auto p : ans){
cout << p << " ";
}
cout << "\n";
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef kaguya
freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
#endif
ll q;
cin >> q;
while (q--){
cin >> n >> t;
forr (i, 1, n){
cin >> a[i].st.nd >> a[i].st.st;
a[i].nd = i;
}
sort(a + 1, a + n + 1);
ll l = 0, r = n;
while (l < r){
ll mid = (l + r) / 2 + 1;
if (check(mid)){
l = mid;
}
else{
r = mid - 1;
}
}
getans(l, check(l));
}
return 0;
}
/*
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5704kb
input:
2 4 100 20 1 40 4 60 3 30 3 1 5 10 1
output:
0 0 0 0
result:
wrong answer jury has a better answer: jans = 2, pans = 0 (test case 1)