QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87238#1895. Moving CellsBeevo#RE 0ms3472kbC++231.1kb2023-03-12 02:02:452023-03-12 02:02:47

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-12 02:02:47]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3472kb
  • [2023-03-12 02:02:45]
  • Submitted

answer

#include <bits/stdc++.h>

#define el '\n'

typedef long long ll;
typedef long double ld;

#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void testCase() {
    int n, m;
    cin >> n >> m;

    int u[m + 1], d[m + 1];
    for (int j = 1; j <= m; j++)
        cin >> u[j] >> d[j];

    ll dp[n + 1][m + 2];

    memset(dp, '?', sizeof dp);

    for (int i = 1; i <= m; i++)
        dp[i][1] = 0;

    multiset<ll> cur, rem[n + 1];
    for (int j = 1; j <= m; j++) {
        for (int i = 1; i + d[j] - u[j] <= n; i++) {
            cur.insert(dp[i][j] + abs(i - u[j]));
            rem[i + d[j] - u[j]].insert(dp[i][j] + abs(i - u[j]));

            dp[i][j + 1] = *cur.begin();

            while (rem[i].size())
                cur.erase(cur.find(*rem[i].begin())), rem[i].erase(rem[i].begin());
        }
    }

    ll mn = dp[1][m + 1];
    for (int i = 2; i <= n; i++)
        mn = min(mn, dp[i][m + 1]);

    cout << mn;
}

signed main() {
    Beevo

    int t = 1;
//    cin >> t;

    while (t--)
        testCase();

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3472kb

input:

9 3
1 2
4 5
7 9

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: -100
Runtime Error

input:

1 5
1 1
1 1
1 1
1 1
1 1

output:


result: