QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#633910#9450. Balloon Robotucup-team4435#AC ✓105ms5256kbC++202.4kb2024-10-12 16:24:062024-10-12 16:24:09

Judging History

你现在查看的是测评时间为 2024-10-12 16:24:09 的历史记录

  • [2024-10-14 16:42:36]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:95ms
  • 内存:5296kb
  • [2024-10-14 16:40:52]
  • hack成功,自动添加数据
  • (/hack/990)
  • [2024-10-12 16:24:09]
  • 评测
  • 测评结果:100
  • 用时:105ms
  • 内存:5256kb
  • [2024-10-12 16:24:06]
  • 提交

answer

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto &x : a)
#define ar array
#define vec vector
#define range(i, n) rep(i, n)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;

int Bit(int mask, int b) { return (mask >> b) & 1; }

template<class T>
bool ckmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool ckmax(T &a, const T &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

// [l, r)
template<typename T, typename F>
T FindFirstTrue(T l, T r, const F &predicat) {
    --l;
    while (r - l > 1) {
        T mid = l + (r - l) / 2;
        if (predicat(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}


template<typename T, typename F>
T FindLastFalse(T l, T r, const F &predicat) {
    return FindFirstTrue(l, r, predicat) - 1;
}


const ll INF = 2e18;
const int INFi = 2e9;
const int N = 5e5 + 5;
const int LG = 20;

void solve() {
    int n, m, p; cin >> n >> m >> p;
    vi s(n);
    rep(i, n) cin >> s[i];
    vl c(p);
    rep(i, p) {
       ll A, B; cin >> A >> B;
       A = s[A - 1] - 1;
       A -= B;
       A %= m;
       if (A < 0) A += m;
       c[i] = A;
    }
    sort(all(c));

    vl ps(p + 1);
    ps[0] = 0;
    rep(i, p) ps[i + 1] = ps[i] + c[i];

    ll ans = INF;
    rep(i, p) {
        ll cur = ps[p];
        cur += 1ll * i * m;
        cur -= 1ll * c[i] * p;
        ckmin(ans, cur);
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(12) << fixed;
    int t = 1;
    cin >> t;
    rep(i, t) {
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3816kb

input:

4
2 3 3
1 2
1 1
2 1
1 4
2 3 5
1 2
1 1
2 1
1 2
1 3
1 4
3 7 5
3 5 7
1 5
2 1
3 3
1 5
2 5
2 100 2
1 51
1 500
2 1000

output:

1
4
5
50

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 105ms
memory: 5256kb

input:

1004
22 9426 26
1165 5248 8331 9055 1161 7381 2188 7489 5131 8434 2166 3981 6302 7188 4858 856 7797 9129 7839 1676 25 9053
20 6
22 68
12 16
11 63
17 49
5 10
21 68
17 80
18 18
10 28
15 55
14 80
1 45
21 67
5 74
13 4
3 34
7 80
9 95
5 52
8 31
2 53
7 22
5 99
20 66
12 2
33 9526 92
558 7460 280 7952 5186 9...

output:

94067
360219
223074
30971
171844
312753
0
158169
294738
291604
115632
59327
221328
287851
30518
337118
181724
249419
66367
10347
208411
180496
287130
40736
264604
278208
33792
191523
111583
31867
21143
232153
149868
191831
238832
63626
258936
133059
105618
237774
53942
342921
275883
110295
149350
20...

result:

ok 1004 lines

Extra Test:

score: 0
Extra Test Passed