QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#681103#9447. Admired PersonRico64Compile Error//C++23743b2024-10-27 01:03:182024-10-27 01:03:19

Judging History

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

  • [2024-10-27 01:03:19]
  • 评测
  • [2024-10-27 01:03:18]
  • 提交

answer

#include <iostream>

using namespace std;

int main() {
    int m, n;
    cin >> n >> m;
    long long arr[n];
    long long brr[m];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    for (int i = 0; i < m; ++i) cin >> brr[i];
    sort(arr, arr + n);
    sort(brr, brr + m);
    long long dp[n+1][m+1];
    fill(dp[0], dp[0] + (m + 1), INT64_MAX / 2);
    for (int i = 0; i <= n; ++i) dp[i][0] = 0;
    for (int x = 1; x <= n; ++x) {
        for (int y = 1; y <= m; ++y) {
            dp[x][y] = dp[x-1][y];
            dp[x][y] = min(dp[x][y], dp[x-1][y-1] + abs(arr[x-1] - brr[y - 1]));
//            cout << dp[x][y] << ' ';
        }
//        cout << endl;
    }
    cout << dp[n][m] << endl;

    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:12:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   12 |     sort(arr, arr + n);
      |     ^~~~
      |     short
answer.code:15:34: error: ‘INT64_MAX’ was not declared in this scope
   15 |     fill(dp[0], dp[0] + (m + 1), INT64_MAX / 2);
      |                                  ^~~~~~~~~
answer.code:2:1: note: ‘INT64_MAX’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    1 | #include <iostream>
  +++ |+#include <cstdint>
    2 |