QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#546391#8866. Drying Laundryzezoo050WA 244ms5972kbC++231.5kb2024-09-04 00:26:142024-09-04 00:26:14

Judging History

This is the latest submission verdict.

  • [2024-09-04 00:26:14]
  • Judged
  • Verdict: WA
  • Time: 244ms
  • Memory: 5972kb
  • [2024-09-04 00:26:14]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;
const int N = 3e5 + 10, M = N - 10;
int n, q;
bitset<N> bt;
array<int, 3> arr[N];
int suf[N];

int get(int x) {
    return M - x;
}

void solve() {
    cin >> n >> q;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> arr[i][2] >> arr[i][1] >> arr[i][0];
        sum += arr[i][2];
    }

    sort(arr, arr + n);

    vector<pair<int, int>> v;

    suf[n - 1] = arr[n - 1][1];
    for (int i = n - 2; i >= 0; i--) {
        suf[i] = max(suf[i + 1], arr[i][1]);
    }

    bt[get(0)] = true;

    long long before = 0;
    for (int i = 0; i < n; i++) {
        bt |= bt >> arr[i][2];
        before += arr[i][2];
        sum -= arr[i][2];
        if (before + sum * 2 > M * 2)
            continue;
        auto it = (int) bt._Find_next(get((int) (before) / 2) - 1);
        v.emplace_back(max(get(it), (int) before - get(it)) + sum, max(suf[i + 1], arr[i][0]));
    }
    std::sort(v.begin(), v.end());
    while (q--) {
        int l;
        cin >> l;
        auto it = std::upper_bound(v.begin(), v.end(), make_pair(l, (int) 1e9 + 7));
//        auto it = v.begin();
        if (it == v.begin()) {
            cout << "-1\n";
            continue;
        }
        it--;
        cout << it->second << '\n';
    }
}

int32_t main() {
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    int t = 1;

//    cin >> t;

    cout << fixed << setprecision(10);
    while (t--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 244ms
memory: 5972kb

input:

30000 300000
2 255945072 661001220
2 68592698 870026391
2 297602072 943696446
2 423786358 574645263
2 178914703 647767179
2 198609024 717883631
2 167020579 942479667
2 63119081 995866587
2 347306369 881413517
2 58674847 601956876
2 110801873 707995015
2 155453326 765668358
2 438060979 649128264
2 20...

output:

-1
780386172
-1
882630795
-1
-1
694190157
535268040
-1
-1
822780178
867163401
-1
-1
787724542
-1
-1
843406425
-1
608088477
-1
678487355
611519637
956002698
-1
-1
691131846
-1
-1
812320879
-1
677850117
-1
537706551
-1
893747900
786791412
-1
-1
715094556
-1
810021220
724602450
950838618
686685989
-1
-...

result:

wrong answer 6818th lines differ - expected: '500181714', found: '500219178'