QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290032#7622. Yet Another Coffeeyllcm#WA 0ms7860kbC++141.6kb2023-12-24 09:54:242023-12-24 09:54:24

Judging History

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

  • [2023-12-24 09:54:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7860kb
  • [2023-12-24 09:54:24]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define db double
#define ull unsigned long long
#define eb emplace_back
#define pii pair<int, int>
#define FR first
#define SE second
#define int long long
using namespace std;
inline int read() {
  int x = 0; bool op = false;
  char c = getchar();
  while(!isdigit(c))op |= (c == '-'), c = getchar();
  while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return op ? -x : x;
}
const int N = 2e5 + 10;
const int INF = 1e18;
int n, m;
int a[N], b[N], sum[N], vis[N], p[N], q[N];
void solve() {
  n = read(); m = read();
  for(int i = 1; i <= n; i++)a[i] = read();
  for(int i = 1; i <= n; i++)b[i] = 0;
  for(int i = 1; i <= m; i++) {
    int r = read(), w = read();
    b[r] -= w;
  }
  for(int i = 1; i <= n; i++)vis[i] = false;
  for(int i = n - 1; i; i--)b[i] += b[i + 1];
  for(int i = 1; i <= n; i++)b[i] += a[i];
  for(int i = 1; i <= n; i++)p[i] = q[i] = i;
  sort(p + 1, p + 1 + n, [&](int x, int y) {return a[x] < a[y];});
  sort(q + 1, q + 1 + n, [&](int x, int y) {return b[x] < b[y];});
  int res = 0, pos = 0;
  for(int i = 1, j = 1, k = 1; i <= n; i++) {
    if(i == 1)res += b[q[j]], pos = q[j], vis[pos] = true, j++;
    else {
      while(j <= n && vis[p[j]])j++;
      while(k <= n && vis[q[k]])k++;
      int v1 = a[p[j]], v2 = a[pos] - b[pos] + b[q[k]];
      if(v1 < v2)res += v1, vis[p[j]] = true;
      else res += v2, vis[q[k]] = true;
    }
    printf("%lld ", res);
  }
  putchar('\n');
  return ;
}
signed main() {
  int test = read();
  while(test--)solve();
  return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7860kb

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 -3487 -3445 -3390 -3331 -3245 -3157 -2897 -2593 -2287 -1963 -1963 
-6527 -6479 -6405 -6289 -6123 -5953 -5774 -5594 -5399 -5198 -4965 -4722 -4459 -4187 -3906 -3622 -3303 -2977 -2977 
-3219 -2804 -2372 -1939 -1470 -1000 -506 11 814 161...

result:

wrong answer 12th numbers differ - expected: '-3491', found: '-3487'