# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1040260 | 2024-07-31T21:07:55 Z | MarwenElarbi | Road Construction (JOI21_road_construction) | C++17 | 849 ms | 15424 KB |
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define pb push_back #define fi first #define se second #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; int main(){ optimise; int n,k; cin>>n>>k; vector<pair<ll,ll>> tab(n); for (int i = 0; i < n; ++i) { cin>>tab[i].fi>>tab[i].se; } sort(tab.begin(),tab.end()); priority_queue<ll> pq; for (int i = 0; i < n; ++i) { for (int j = i-1; j >= max(0,i-1000) ; j--) { ll cur=abs(tab[i].fi-tab[j].fi)+abs(tab[i].se-tab[j].se); if(pq.size()<k) pq.push(cur); else{ if(pq.top()>cur){ pq.pop(); pq.push(cur); } } } } vector<ll> ans(k); for (int i = 0; i < k; ++i) { ans[i]=pq.top(); pq.pop(); } reverse(ans.begin(),ans.end()); for (int i = 0; i < k; ++i) { cout <<ans[i]<<endl; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 244 ms | 6848 KB | Output is correct |
2 | Correct | 246 ms | 7108 KB | Output is correct |
3 | Correct | 233 ms | 7108 KB | Output is correct |
4 | Correct | 232 ms | 7108 KB | Output is correct |
5 | Correct | 266 ms | 5824 KB | Output is correct |
6 | Correct | 4 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 766 ms | 9420 KB | Output is correct |
2 | Correct | 798 ms | 9672 KB | Output is correct |
3 | Correct | 241 ms | 6952 KB | Output is correct |
4 | Correct | 753 ms | 9356 KB | Output is correct |
5 | Correct | 675 ms | 9672 KB | Output is correct |
6 | Correct | 685 ms | 9672 KB | Output is correct |
7 | Correct | 687 ms | 8760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 411 ms | 4188 KB | Output is correct |
2 | Correct | 392 ms | 4184 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 390 ms | 7052 KB | Output is correct |
5 | Correct | 397 ms | 9556 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 411 ms | 4188 KB | Output is correct |
2 | Correct | 392 ms | 4184 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 390 ms | 7052 KB | Output is correct |
5 | Correct | 397 ms | 9556 KB | Output is correct |
6 | Correct | 409 ms | 9216 KB | Output is correct |
7 | Correct | 402 ms | 9344 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 456 KB | Output is correct |
10 | Correct | 426 ms | 9352 KB | Output is correct |
11 | Correct | 404 ms | 7248 KB | Output is correct |
12 | Correct | 395 ms | 9620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 244 ms | 6848 KB | Output is correct |
2 | Correct | 246 ms | 7108 KB | Output is correct |
3 | Correct | 233 ms | 7108 KB | Output is correct |
4 | Correct | 232 ms | 7108 KB | Output is correct |
5 | Correct | 266 ms | 5824 KB | Output is correct |
6 | Correct | 4 ms | 348 KB | Output is correct |
7 | Correct | 545 ms | 10064 KB | Output is correct |
8 | Correct | 554 ms | 9928 KB | Output is correct |
9 | Correct | 242 ms | 7108 KB | Output is correct |
10 | Correct | 540 ms | 9164 KB | Output is correct |
11 | Correct | 607 ms | 9164 KB | Output is correct |
12 | Correct | 465 ms | 9984 KB | Output is correct |
13 | Correct | 453 ms | 8608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 244 ms | 6848 KB | Output is correct |
2 | Correct | 246 ms | 7108 KB | Output is correct |
3 | Correct | 233 ms | 7108 KB | Output is correct |
4 | Correct | 232 ms | 7108 KB | Output is correct |
5 | Correct | 266 ms | 5824 KB | Output is correct |
6 | Correct | 4 ms | 348 KB | Output is correct |
7 | Correct | 766 ms | 9420 KB | Output is correct |
8 | Correct | 798 ms | 9672 KB | Output is correct |
9 | Correct | 241 ms | 6952 KB | Output is correct |
10 | Correct | 753 ms | 9356 KB | Output is correct |
11 | Correct | 675 ms | 9672 KB | Output is correct |
12 | Correct | 685 ms | 9672 KB | Output is correct |
13 | Correct | 687 ms | 8760 KB | Output is correct |
14 | Correct | 411 ms | 4188 KB | Output is correct |
15 | Correct | 392 ms | 4184 KB | Output is correct |
16 | Correct | 0 ms | 344 KB | Output is correct |
17 | Correct | 390 ms | 7052 KB | Output is correct |
18 | Correct | 397 ms | 9556 KB | Output is correct |
19 | Correct | 409 ms | 9216 KB | Output is correct |
20 | Correct | 402 ms | 9344 KB | Output is correct |
21 | Correct | 0 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 456 KB | Output is correct |
23 | Correct | 426 ms | 9352 KB | Output is correct |
24 | Correct | 404 ms | 7248 KB | Output is correct |
25 | Correct | 395 ms | 9620 KB | Output is correct |
26 | Correct | 545 ms | 10064 KB | Output is correct |
27 | Correct | 554 ms | 9928 KB | Output is correct |
28 | Correct | 242 ms | 7108 KB | Output is correct |
29 | Correct | 540 ms | 9164 KB | Output is correct |
30 | Correct | 607 ms | 9164 KB | Output is correct |
31 | Correct | 465 ms | 9984 KB | Output is correct |
32 | Correct | 453 ms | 8608 KB | Output is correct |
33 | Correct | 849 ms | 15304 KB | Output is correct |
34 | Correct | 831 ms | 15360 KB | Output is correct |
35 | Correct | 817 ms | 14580 KB | Output is correct |
36 | Correct | 687 ms | 15424 KB | Output is correct |
37 | Correct | 666 ms | 15308 KB | Output is correct |
38 | Correct | 725 ms | 14024 KB | Output is correct |