QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149282#2572. Box PackingwaynetuWA 2ms3620kbC++17772b2023-08-24 12:40:312023-08-24 12:40:34

Judging History

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

  • [2023-08-24 12:40:34]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3620kb
  • [2023-08-24 12:40:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<pair<int, int>> vec(N);
  for (int i = 0; i < N; ++i) {
    cin >> vec[i].first >> vec[i].second;
  }
  sort(vec.begin(), vec.end());
  vector<vector<int>> lis(K);
  for (auto [_, v] : vec) {
    for (int i = 0; i < K; ++i) {
      if (lis[i].empty() || lis[i].back() <= v) {
        lis[i].push_back(v);
        break;
      } else {
        auto it = lower_bound(lis[i].begin(), lis[i].end(), v);
        int t = *it;
        *it = v;
        v = t;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < K; ++i) {
    res += lis[i].size();
  }
  cout << res << "\n";
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3516kb

input:

4 1
2 2
4 2
3 4
5 5

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

4 2
2 2
4 2
3 4
5 5

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

10 2
8 12
15 5
13 19
11 5
2 13
13 12
5 6
8 6
14 2
16 3

output:

7

result:

ok 1 number(s): "7"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

10 2
16 4
2 5
11 16
15 5
6 12
2 1
9 16
9 10
12 11
11 17

output:

8

result:

ok 1 number(s): "8"

Test #5:

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

input:

10 2
1 6
17 9
14 19
11 14
10 17
16 1
6 13
10 13
2 2
9 7

output:

8

result:

ok 1 number(s): "8"

Test #6:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

10 2
4 20
17 11
2 10
18 10
7 14
17 5
16 2
3 16
6 6
9 18

output:

6

result:

ok 1 number(s): "6"

Test #7:

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

input:

10 5
2 5
6 18
5 13
8 13
7 10
19 3
14 20
12 5
1 7
18 18

output:

10

result:

ok 1 number(s): "10"

Test #8:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

10 5
2 9
3 1
6 17
12 19
20 15
4 14
14 19
18 15
7 20
20 12

output:

10

result:

ok 1 number(s): "10"

Test #9:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

10 5
10 7
15 2
19 15
10 18
19 17
6 5
11 9
13 3
4 20
11 16

output:

10

result:

ok 1 number(s): "10"

Test #10:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

10 5
4 6
17 17
13 11
17 12
4 3
11 18
20 5
10 9
8 9
4 1

output:

10

result:

ok 1 number(s): "10"

Test #11:

score: -100
Wrong Answer
time: 2ms
memory: 3620kb

input:

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

output:

7

result:

wrong answer 1st numbers differ - expected: '8', found: '7'