# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
704102 | 2023-03-01T15:08:54 Z | 1075508020060209tc | Coin Collecting (JOI19_ho_t4) | C++14 | 1 ms | 308 KB |
//#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n; pair<int,int>ar[500005]; int vsa[500005]; int vsb[500005]; signed main(){ cin>>n; for(int i=1;i<=n+n;i++){ cin>>ar[i].X>>ar[i].Y; } vector<pair<int,pair<int,int>>>seq; for(int j=1;j<=n;j++){ for(int i=1;i<=n+n;i++){ int cst=abs(ar[i].X-j)+abs(ar[i].Y-1); seq.push_back({cst,{i,j}}); } } for(int j=1;j<=n;j++){ for(int i=1;i<=n+n;i++){ int cst=abs(ar[i].X-j)+abs(ar[i].Y-2); seq.push_back({cst,{i,j+n}}); } } sort(seq.begin(),seq.end()); int ans=0; for(int i=0;i<seq.size();i++){ if(vsa[seq[i].second.first]==0&&vsb[seq[i].second.second]==0){ ans+=seq[i].first; } } cout<<ans<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |