QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#72718 | #2572. Box Packing | CSU2023# | WA | 1ms | 9412kb | C++14 | 1.1kb | 2023-01-18 10:48:25 | 2023-01-18 10:48:28 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define mk make_pair
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int N = 2E5 + 3;
int n,k;
struct node{
int ai;
int bi;
}v[N];
vector<int> a[N];
void insert(int x) {
// cout << x << endl;
for (int i = 0;i <= k; i++) {
auto it = upper_bound(a[i].begin(), a[i].end(), x);
if (it == a[i].end()) {
a[i].push_back(x);
// cout << i << " " << a[i].size() << endl;
return;
}
// printf("%d\n",*it);
swap(x, *it);
}
}
inline int read(){
int v = 0,c = 1;char ch = getchar();
while(!isdigit(ch)){
if(ch == '-') c = -1;
ch = getchar();
}
while(isdigit(ch)){
v = v * 10 + ch - 48;
ch = getchar();
}
return v * c;
}
inline bool cmp(node x,node y){
return x.ai < y.ai;
}
int main(){
n = read(),k = read();
for(int i = 1;i <= n;++i){
v[i].ai = read();
v[i].bi = read();
}
sort(v + 1,v + n + 1,cmp);
for(int i = 1;i <= n;++i) insert(v[i].bi);
int ans = 0;
for(int i = 0;i < k;++i) ans += a[i].size();
cout << ans << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 9412kb
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: 0ms
memory: 9008kb
input:
4 2 2 2 4 2 3 4 5 5
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 8136kb
input:
10 2 8 12 15 5 13 19 11 5 2 13 13 12 5 6 8 6 14 2 16 3
output:
5
result:
wrong answer 1st numbers differ - expected: '7', found: '5'