QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#126782#2784. Alienssomethingnew#0 0ms4048kbC++201.7kb2023-07-18 23:46:112024-07-04 00:45:19

Judging History

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

  • [2024-07-04 00:45:19]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:4048kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-18 23:46:11]
  • 提交

answer

//  ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
//  ➡ @roadfromroi ⬅
//  ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#include "aliens.h"
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
ll sq(ll a) {
    return a * a;
}
pair<ll, int> reba(int n, vector<pair<int, int>> opp, ll cc) {
    vector<int> cnt(n + 1);
    vector<ll> dp(n + 1, 1e18);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            ll vl = dp[i] + sq(opp[i].first - opp[j-1].second) + cc;
            if (dp[j] < vl) {
                dp[j] = vl;
                cnt[j] = cnt[i] + 1;
            }
        }
    }
    return {dp[n], cnt[n]};
}
ll take_photos(int n, int m, int k, vector<int> re, vector<int> c) {
    vector<pair<int, int>> sgg(n);
    for (int i = 0; i < n; ++i) {
        sgg[i] = {min(re[i], c[i]), max(re[i], c[i])};
    }
    sort(all(sgg));
    vector<pair<int, int>> bb;
    for (auto [l, r] : sgg) {
        while (!bb.empty() and l == bb.back().first)
            bb.pop_back();
        if (bb.empty() or bb.back().second < r) {
            bb.push_back({l, r});
        }
    }
    sgg = bb;
    n = sgg.size();
    ll l = 0, r = (ll)1e14;
    while (l + 1 < r) {
        ll m = l + r >> 1ll;
        if (reba(n, sgg, m).second <= k) {
            l = m;
        } else {
            r = m;
        }
    }
    pair<ll, int> val = reba(n, sgg, l);
    return val.first - l * val.second + l * (k-val.second);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4048kb

input:

2 6 2
1 4
4 1

output:

098d134608c94f7413faac591054ee35
1000199999999999998

result:

wrong answer Wrong answer: output = 1000199999999999998, expected = 16

Subtask #2:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 0ms
memory: 3856kb

input:

2 2 1
0 0
1 1

output:

098d134608c94f7413faac591054ee35
1000000000000000000

result:

wrong answer Wrong answer: output = 1000000000000000000, expected = 4

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%