# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
922089 | 2024-02-05T02:27:47 Z | guagua0407 | Road Construction (JOI21_road_construction) | C++17 | 382 ms | 13216 KB |
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int dx[4]={0,0,1,-1}; int dy[4]={1,-1,0,0}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int inf=2e9+5; int n,k; vector<pair<int,int>> vec; vector<ll> ans; bool check(ll d){ int l=0; set<pair<int,int>> S; ans.clear(); for(int r=0;r<n;r++){ while(vec[l].f<max(-(ll)inf,(ll)vec[r].f-d)){ S.erase({vec[l].s,l}); l++; } auto it2=S.upper_bound({vec[r].s+d,inf}); for(auto it=S.lower_bound({vec[r].s-d,-inf});it!=it2;it++){ int x=(*it).s; ans.push_back(max(abs((ll)vec[x].f-(ll)vec[r].f),abs((ll)vec[x].s-(ll)vec[r].s))); if((int)ans.size()>=k) return true; } S.insert({vec[r].s,r}); } return false; } int main() {_ cin>>n>>k; for(int i=0;i<n;i++){ int x,y; cin>>x>>y; int xx=y+x; int yy=y-x; vec.push_back({xx,yy}); } sort(all(vec)); ll l=0,r=(ll)4e9; while(l<r){ ll mid=(l+r)/2; if(check(mid)){ r=mid; } else{ l=mid+1; } } check(l-1); sort(all(ans)); while((int)ans.size()<k) ans.push_back(l); for(auto v:ans){ cout<<v<<'\n'; } return 0; } //maybe its multiset not set //yeeorz //laborz
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 53 ms | 5064 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 343 ms | 13040 KB | Output is correct |
2 | Correct | 338 ms | 13216 KB | Output is correct |
3 | Incorrect | 42 ms | 5072 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 198 ms | 6428 KB | Output is correct |
2 | Correct | 256 ms | 6596 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 123 ms | 4912 KB | Output is correct |
5 | Correct | 324 ms | 6856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 198 ms | 6428 KB | Output is correct |
2 | Correct | 256 ms | 6596 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 123 ms | 4912 KB | Output is correct |
5 | Correct | 324 ms | 6856 KB | Output is correct |
6 | Correct | 382 ms | 6540 KB | Output is correct |
7 | Correct | 351 ms | 6372 KB | Output is correct |
8 | Incorrect | 1 ms | 344 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 53 ms | 5064 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 53 ms | 5064 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |