Submission #204117

#TimeUsernameProblemLanguageResultExecution timeMemory
204117tduong0806Coin Collecting (JOI19_ho_t4)C++14
0 / 100
5 ms380 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define int long long int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;} #define in hmt() #define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;}) #define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i) #define fordec(i,a,b) for(int i=a;i>=b;--i) #define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i)) #define forv(a,b) for(auto &a:b) #define pb push_back #define pii pair<int,int> #define fi first #define se second #define all(a) a.begin(),a.end() #define reset(f,x) memset(f,x,sizeof(f)) #define bit(x,i) ((x>>(i-1))&1) #define onbit(x,i) (x|(1<<(i-1))) #define offbit(x,i) (x&~(1<<(i-1))) const int N=2e5+10; int n; pii a[N]; int l(pii x,pii y) { return abs(x.fi-y.fi)+abs(x.se-y.se); } main() { //freopen("JOI2019.inp","r",stdin); n=in; forinc(i,1,2*n) a[i]={in,in}; sort(a+1,a+2*n+1); int ans=0; forinc(i,1,n) ans+=min(l(a[2*i-1],{i,1})+l(a[2*i],{i,2}),l(a[2*i],{i,1})+l(a[2*i-1],{i,2})); reverse(a+1,a+2*n+1); int kq=0; fordec(i,n,1) kq+=min(l(a[2*i-1],{i,1})+l(a[2*i],{i,2}),l(a[2*i],{i,1})+l(a[2*i-1],{i,2})); cout<<min(ans,kq)<<"\n"; }

Compilation message (stderr)

joi2019_ho_t4.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...