結果
問題 | No.3016 ハチマキおじさん |
ユーザー |
![]() |
提出日時 | 2025-01-25 13:31:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 229 ms / 2,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 1,720 ms |
コンパイル使用メモリ | 175,532 KB |
実行使用メモリ | 24,832 KB |
最終ジャッジ日時 | 2025-01-25 22:49:33 |
合計ジャッジ時間 | 7,579 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge11 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<VL> VVL; typedef long long LL; #define all(a) (a).begin(), (a).end() #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define ALL(a) (a).begin(),(a).end() #define pb push_back int main() { int n;cin>>n; int A[n],B[n-1]; rep(i,n){cin>>A[i];} rep(i,n-1){cin>>B[i];} sort(A,A+n); sort(B,B+n-1); map<LL,set<int>> ans; LL L[n-1],R[n-1]; rep(i,n-1){L[i]=abs(A[i]-B[i]);} rep(i,n-1){R[i]=abs(A[i+1]-B[i]);} rep(i,n-2){L[i+1]+=L[i];} for(int i=n-3;i>=0;i--){R[i]+=R[i+1];} //rep(i,n-1){cout<<R[i]<<' ';}cout<<endl; rep(i,n){ LL ss; if(i==0){ss=R[0];} else if(i==n-1){ss=L[n-2];} else{ss=L[i-1]+R[i];} //cout<<i<<' '<<ss<<endl; ans[ss].insert(A[i]); } auto it=*ans.begin(); set<int> D=(it).second; cout<<D.size()<<endl; for(int it : D){ cout<<it<<' '; }cout<<endl; }