답안 #623040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
623040 2022-08-05T06:20:07 Z CSQ31 Road Construction (JOI21_road_construction) C++17
5 / 100
1985 ms 2097152 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//consider the case where we only need k smallest from two different set of points
//if can do this in some reasonable time then apply zs bit trick
//+log factor
//need <= log^3 maybe?
//ok two set need log^2(?)
#define all(a) a.begin(),a.end()
#define pb push_back
const int MAXN = 2000000;
int ndcnt = 0;
int t[MAXN],ch[2][MAXN];
vector<ll>glo;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<array<int,2>>p(n);
	vector<int>cy(n),cxy(n);
	for(int i=0;i<n;i++)cin>>p[i][0]>>p[i][1];
	sort(all(p));
	vector<int>crd;
	for(int i=0;i<n;i++)crd.push_back(p[i][1]);
	sort(all(crd));
	crd.resize(unique(all(crd)) - crd.begin());
	for(int i=0;i<n;i++)cy[i] = lower_bound(all(crd),p[i][1]) - crd.begin();
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			ll c = abs(p[i][0]-p[j][0]);
			c+=abs(p[i][1]-p[j][1]);
			glo.pb(c);	
		}
	}
	sort(all(glo));
	for(int i=0;i<k;i++)cout<<glo[i]<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 6948 KB Output is correct
2 Correct 64 ms 6884 KB Output is correct
3 Correct 42 ms 5004 KB Output is correct
4 Correct 41 ms 5048 KB Output is correct
5 Correct 60 ms 5792 KB Output is correct
6 Correct 23 ms 4548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1963 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1985 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1985 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 6948 KB Output is correct
2 Correct 64 ms 6884 KB Output is correct
3 Correct 42 ms 5004 KB Output is correct
4 Correct 41 ms 5048 KB Output is correct
5 Correct 60 ms 5792 KB Output is correct
6 Correct 23 ms 4548 KB Output is correct
7 Runtime error 1777 ms 2097152 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 6948 KB Output is correct
2 Correct 64 ms 6884 KB Output is correct
3 Correct 42 ms 5004 KB Output is correct
4 Correct 41 ms 5048 KB Output is correct
5 Correct 60 ms 5792 KB Output is correct
6 Correct 23 ms 4548 KB Output is correct
7 Runtime error 1963 ms 2097152 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -