#include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<tr1/unordered_map> #include<queue> #include<cstdlib> #include<list> #include<set> #include<map> #include<cmath> #define MP make_pair #define PB push_back #define s second #define f first #define PII pair<int,int> #define VPII vector <pair<int,int> > #define VI vector <int> #define abs(a) max((a),-(a)) #define LL long long #define LD long double #define ALL(x) x.begin(),x.end() #define PU putchar_unlocked #define GU getchar_unlocked #define DBG(x) cerr<<#x<<" "<<(x)<<endl; using namespace std; int a,b,c,d,e,f,n,m,mx,l,r,k; LL wynik; char ch; LL INF=1e18+1; const int MXN=1e5+4; int t[6][MXN]; LL odl(int a,int b) { LL ret=0; for(int i=1;i<=n;i++) { ret+=abs(t[a][i]-t[b][i]); } return ret; } void solve() { scanf("%d%d",&n,&k); for(int i=1;i<=k;i++) { for(int j=1;j<=n;j++) { scanf("%d",&t[i][j]); } } pair< LL , PII > wynik; for(int i=1;i<=k;i++) { for(int j=i+1;j<=k;j++) { wynik=max(wynik,MP(odl(i,j),MP(i,j))); } } a=wynik.s.f; b=wynik.s.s; c=0; for(int i=1;i<=n;i++) { if(abs(t[a][i]-t[b][i])%2==0) { printf("%d ",(t[a][i]+t[b][i])/2); } else { printf("%d ",(t[a][i]+t[b][i])/2+c); if(c==0)c=1; else c=0; } } //printf("%lld\n",wynik/2+wynik%2); } main() { solve(); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<tr1/unordered_map> #include<queue> #include<cstdlib> #include<list> #include<set> #include<map> #include<cmath> #define MP make_pair #define PB push_back #define s second #define f first #define PII pair<int,int> #define VPII vector <pair<int,int> > #define VI vector <int> #define abs(a) max((a),-(a)) #define LL long long #define LD long double #define ALL(x) x.begin(),x.end() #define PU putchar_unlocked #define GU getchar_unlocked #define DBG(x) cerr<<#x<<" "<<(x)<<endl; using namespace std; int a,b,c,d,e,f,n,m,mx,l,r,k; LL wynik; char ch; LL INF=1e18+1; const int MXN=1e5+4; int t[6][MXN]; LL odl(int a,int b) { LL ret=0; for(int i=1;i<=n;i++) { ret+=abs(t[a][i]-t[b][i]); } return ret; } void solve() { scanf("%d%d",&n,&k); for(int i=1;i<=k;i++) { for(int j=1;j<=n;j++) { scanf("%d",&t[i][j]); } } pair< LL , PII > wynik; for(int i=1;i<=k;i++) { for(int j=i+1;j<=k;j++) { wynik=max(wynik,MP(odl(i,j),MP(i,j))); } } a=wynik.s.f; b=wynik.s.s; c=0; for(int i=1;i<=n;i++) { if(abs(t[a][i]-t[b][i])%2==0) { printf("%d ",(t[a][i]+t[b][i])/2); } else { printf("%d ",(t[a][i]+t[b][i])/2+c); if(c==0)c=1; else c=0; } } //printf("%lld\n",wynik/2+wynik%2); } main() { solve(); } |