QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#230294#1441. Special GameckisekiWA 0ms3704kbC++141.1kb2023-10-28 18:01:162023-10-28 18:01:40

Judging History

This is the latest submission verdict.

  • [2023-10-28 18:01:40]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3704kb
  • [2023-10-28 18:01:16]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
int a[1010], b[1010], n;
int get_min(int* x) {
  int mn = 100000, cand = 0;
  for(int i = 0; i < n; i++) {
    if(x[i] == 0) continue;
    if(x[i] < mn) {
      mn = x[i];
      cand = i;
    }
  }
  return cand;
}
int get_min_gt(int* x, int tar) {
  int mn = 10000000, cand = -1;
  for(int i = 0; i < n; i++) {
    if(x[i] == 0 || x[i] < tar) continue;
    if(x[i] < mn) {
      mn = x[i];
      cand = i;
    }
  }
  return cand;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int x = get_min(a), y = get_min_gt(b, a[x]);
    if(y == -1) {
      for(int i = 0; i < n; i++) if(a[i]) ans++;
      cout << ans << endl;
      exit(0);
    }
    else {
      a[x] = b[y] = 0;
    }

    x = get_min(b);
    y = get_min_gt(a, b[x]);
    if(y == -1) {
      cout << ans << endl;
      exit(0);
    }
    else {
      a[y] = b[x] = 0;
      ans++;

    }
  }
  return 0;
}

详细

Test #1:

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

input:

3
1 2 5
3 4 6

output:

1

result:

ok "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

2
4 3
1 2

output:

2

result:

ok "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

1
1
2

output:

0

result:

ok "0"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3572kb

input:

9
2 12 10 3 4 7 17 14 16
6 1 13 11 9 15 18 8 5

output:

4

result:

wrong answer 1st words differ - expected: '5', found: '4'