QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745799#8243. Contest AdvancementsuryaaprakasshWA 0ms3652kbC++171.8kb2024-11-14 11:42:202024-11-14 11:42:20

Judging History

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

  • [2024-11-14 11:42:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3652kb
  • [2024-11-14 11:42:20]
  • 提交

answer

#include <bits/stdc++.h>
// pbds
/*#include <ext/pb_ds/assoc_container.hpp> // Common file*/
/*#include <ext/pb_ds/tree_policy.hpp>*/
/**/
/*using namespace __gnu_pbds;*/
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...) 42
#endif
#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define ll long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

/*typedef tree<int, null_type, less<int>, rb_tree_tag,*/
/*             tree_order_statistics_node_update>*/
/*    ordered_set;*/
const int N = 1e5 + 5;
bool vis[N];
void solve() {
  ll n, k, c;
  cin >> n >> k >> c;
  vector<pair<int, int>> vp(n);
  memset(vis, 0, sizeof vis);
  map<ll, ll> mp;
  for (int i = 0; i < n; i++) {
    cin >> vp[i].first;
    cin >> vp[i].second;
    mp[vp[i].second] = c;
  }
  ll curr = 0;
  for (int i = 0; i < n && curr < k; i++) {
    if (mp[vp[i].second] != 0) {
      cout << vp[i].first << "\n";
      mp[vp[i].second]--;
      vis[vp[i].first] = 1;
      curr++;
    }
  }
  int i = 0;
  while (curr < k and i < n) {
    if (!vis[vp[i].first]) {
      vis[vp[i].first] = 1;
      cout << vp[i].first << "\n";
      curr++;
    }
		i++;
  }
  cout << "\n";
}

int main() {
  fast_io;
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("output.txt", "w", stderr);
#endif
  ll t = 1;
  /*cin >> t;*/
  while (t--) {
#ifdef LOCAL
    cout << "TEST CASE " << t + 1 << "\n";
#endif
    solve();
  }
#ifdef LOCAL
  cout << endl
       << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n\n";
#endif
  return 0;
}

详细

Test #1:

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

input:

10 7 3
3 9
1 9
4 9
5 9
9 7
2 7
6 7
7 7
8 5
10 5

output:

3
1
4
9
2
6
8


result:

ok 7 lines

Test #2:

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

input:

10 5 2
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 2

output:

1
2
10
3
4


result:

wrong answer 3rd lines differ - expected: '3', found: '10'