QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#85799#5693. 众数xiafan8050TL 0ms0kbC++20640b2023-03-08 15:41:392023-03-08 15:41:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-08 15:41:43]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-03-08 15:41:39]
  • 提交

answer

/**
 * @author: XiaFan
 * @date: 2023-03-08 14:01
 **/
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }
    i64 ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        i64 sum = a[i];
        for (int j = i - 1; j >= 0; j--) {
            i64 d = std::min(a[i], a[j]);
            sum += d;
            a[j] -= d;
        }
        ans += sum * (i + 1);
    }

    std::cout << ans << "\n";

    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

99991
3 3 3 4 3 6 4 2 2 5 3 2 3 5 3 3 2 1 2 3 4 2 3 4 3 3 3 4 3 3 3 2 3 2 3 2 4 3 3 2 3 5 3 5 4 2 4 3 3 1 3 2 2 3 4 2 3 3 2 2 4 5 3 2 3 3 1 3 3 4 1 3 4 5 1 1 3 4 2 4 3 2 5 3 3 2 2 2 4 2 4 2 2 4 2 4 3 3 2 3 2 2 1 4 3 1 3 1 2 2 3 1 1 5 2 1 2 2 3 3 1 4 4 4 3 3 3 3 1 3 3 5 5 4 4 3 3 3 4 3 6 5 3 1 1 2 2 ...

output:


result: