QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#118995#6626. Real Mountainsbatrr#0 0ms3696kbC++231.8kb2023-07-04 18:04:412024-05-31 19:00:39

Judging History

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

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

answer

#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = 1000500, inf = 1e9, mod = 998244353;
const ll INF = 1e18;

int sum(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mult(int a, int b) {
    return 1ll * a * b % mod;
}

int bp(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

int inv(int x) {
    return bp(x, mod - 2);
}

int n, a[N];
ll ans;

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    while (true) {
        pii cur = {inf, -1};
        for (int i = 1; i + 1 < n; i++)
            if (a[i - 1] > a[i] && a[i] < a[i + 1])
                cur = min(cur, {a[i], i});
        int p = cur.s;
        if (p == -1)
            break;
        int x = inf, y = inf;
        for (int i = 0; i < p; i++)
            if (a[i] > a[p])
                x = min(x, a[i]);
        for (int i = p + 1; i < n; i++)
            if (a[i] > a[p])
                y = min(y, a[i]);
        int cnt = min(x, y) - a[p];
        ans += 1ll * (x + y) * cnt;
        ans += (a[p] + a[p] + cnt - 1) * cnt / 2;
        a[p] += cnt;
    }
    cout << ans << "\n";
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
//        cout << "Case #" << i << endl;
        solve();
    }
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 0ms
memory: 3696kb

input:

3
29 9 9

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

3
62 20 71

output:

7287

result:

ok 1 number(s): "7287"

Test #3:

score: -3
Wrong Answer
time: 0ms
memory: 3644kb

input:

10
72 33 22 22 13 49 53 57 72 85

output:

792

result:

wrong answer 1st numbers differ - expected: '40403', found: '792'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #3:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%