QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691185#9529. Farm ManagementWA_automaton#WA 0ms3648kbC++201.7kb2024-10-31 10:18:402024-10-31 10:18:41

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 10:18:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-10-31 10:18:40]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
void debug() {std::cerr << "\n";}
template<class T, class... OtherArgs>
void debug(T &&var, OtherArgs &&... args) {
    std::cerr << std::forward<T>(var) << " ";
    debug(std::forward<OtherArgs>(args)...);
}
#define SZ(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
using i64 = long long;
using u64 = unsigned long long;
using LD = long double;
using PII = pair<int, int>;
constexpr int N = 300010;
constexpr int P = 1e9 + 7;

void solve() {
    int n, m;
    cin >> n >> m;

    vector<array<int, 3>> a(n);
    int t = 0, cost = 0;
    for (int i = 0; i < n; i++) {
        auto &[w, l, r] = a[i];
        cin >> w >> l >> r;
        m -= l;
        cost += w * l;
    }
    
    sort(all(a));

    vector<int> suf(n + 1), sufres(n + 1);
    for (int i = n - 1; ~i; i--) {
        auto &[w, l, r] = a[i];
        suf[i] = suf[i + 1] + r - l;
        sufres[i] = sufres[i + 1] + (r - l) * w;
    }

    int ans = cost;
    for (int i = 0; i < n; i++) {
        auto &[w, l, r] = a[i];
        int rest = m + l;
        int j = lower_bound(all(suf), rest, greater()) - suf.begin();
        j = min(j, n - 1);
        // debug("?", i, j, rest, sufres[j + 1]);
        rest -= suf[j + 1];
        ans = max(ans, cost - w * l + sufres[j + 1] + rest * a[j][0]);
    }
    cout << ans << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);
    int _ = 1;
    // cin >> _;
    while (_--) {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

input:

5 17
2 3 4
6 1 5
8 2 4
4 3 3
7 5 5

output:

109

result:

ok single line: '109'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

12 62
503792 9 10
607358 1 3
600501 10 10
33249 4 4
774438 6 6
197692 3 6
495807 8 8
790225 5 9
77272 3 8
494819 4 9
894779 3 9
306279 5 6

output:

35204500

result:

ok single line: '35204500'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

15 32
835418 2 3
178262 1 3
527643 2 2
519710 1 1
774544 3 3
82312 1 1
808199 1 1
809396 1 3
255882 1 3
80467 1 3
874973 1 3
813965 1 2
198275 1 2
152356 1 3
802055 1 1

output:

17016847

result:

wrong answer 1st lines differ - expected: '22000255', found: '17016847'