QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#72717#2572. Box PackingCSU2023#WA 4ms9528kbC++141.1kb2023-01-18 10:43:112023-01-18 10:43:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-18 10:43:12]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:9528kb
  • [2023-01-18 10:43:11]
  • 提交

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++) {
		auto it = lower_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: 2ms
memory: 9404kb

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: 8284kb

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: 4ms
memory: 9528kb

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'