QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657895#7622. Yet Another Coffeewdbl857WA 1ms5916kbC++201.7kb2024-10-19 15:40:102024-10-19 15:40:11

Judging History

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

  • [2024-10-19 15:40:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5916kb
  • [2024-10-19 15:40:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define xx first
#define yy second
#define endl "\n"
#define pb push_back
#define int long long
#define ll long long
#define lowbit(x) x & (-x)
typedef pair<int, int> pii;
#define LF(x) fixed << setprecision(x)
#define Yshanqian ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int N = 1e6 + 10, M = 1010, inf = 0x3f3f3f3f, mod = 1e9 + 7, P = 13331;
int n, m;
int a[N], day[N];
void solve()
{
    int s1 = 0, s2 = 0;
    cin >> n >> m;
    vector<int> ans(n + 1, 0);
    for (int i = 1; i <= n; i++)
        day[i] = 0;
    for (int i = 1; i <= n; i++)
        cin >> a[i], s1 += a[i];
    for (int i = 1; i <= m; i++)
    {
        int r, w;
        cin >> r >> w;
        day[r] += w;
        s2 += w;
    }
    multiset<int> st;
    for (int i = 2; i <= n; i++)
        st.insert(-a[i]);
    st.insert(-a[1] + day[1]);
    int nowmn = 1, nowval = -a[1] + day[1];
    ans[n] = s1 - s2;
    for (int i = n - 1; i >= 1; i--)
    {
        auto it = st.begin();
        ans[i] = ans[i + 1] + *it;
        if (*it == nowval)
        {
            st.erase(st.find(*it));
            nowmn++;
            if (st.find(-a[nowmn]) != st.end())
                st.erase(st.find(-a[nowmn]));
            st.insert(day[nowmn] - a[nowmn]);
            nowval = day[nowmn] - a[nowmn];
        }
        else
            st.erase(st.find(*it));
    }
    for (int i = 1; i <= n; i++)
        cout << ans[i] << " ";
    cout << endl;
}
signed main()
{
    Yshanqian;
    int T;
    T = 1;
    cin >> T;
    for (int cases = 1; cases <= T; ++cases)
    {
        // cout<<"Case #"<<cases<<": ";
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5916kb

input:

5
10 14
17 37 59 65 53 73 68 177 160 111
10 177
5 193
2 30
3 63
2 339
3 263
5 178
2 190
9 23
10 328
10 200
9 8
3 391
6 230
12 9
152 306 86 88 324 59 18 14 42 260 304 55
3 50
2 170
1 252
7 811
1 713
7 215
10 201
4 926
8 319
19 20
182 74 180 201 326 243 195 31 170 263 284 233 48 166 272 281 179 116 31...

output:

-2596 -2559 -2506 -2447 -2382 -2314 -2241 -2130 -1970 -1793 
-3505 -3491 -3473 -3431 -3376 -3317 -3231 -3143 -2883 -2579 -2273 -1949 
-6527 -6496 -6448 -6374 -6258 -6092 -5922 -5743 -5563 -5368 -5167 -4934 -4691 -4428 -4156 -3875 -3591 -3272 -2946 
-3242 -2987 -2572 -2140 -1707 -1238 -768 -274 243 1...

result:

wrong answer 42nd numbers differ - expected: '-3219', found: '-3242'