結果
| 問題 |
No.3016 ハチマキおじさん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-11 15:35:09 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,723 bytes |
| コンパイル時間 | 3,480 ms |
| コンパイル使用メモリ | 286,724 KB |
| 実行使用メモリ | 8,064 KB |
| 最終ジャッジ日時 | 2025-02-11 15:35:18 |
| 合計ジャッジ時間 | 8,171 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 25 |
ソースコード
#include <cctype>
#include <string>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <chrono>
using namespace std;
using ll = long long;
using pii = pair<int,int>;using pll = pair<ll,ll>;using pci = pair<char,int>;
using vi = vector<int>;using vl = vector<ll>;using vs = vector<string>;using vb = vector<bool>;using vc = vector<char>;
using vpii = vector<pii>;using vpll = vector<pll>;using vpci = vector<pci>;
using vvi = vector<vector<int>>;using vvl = vector<vector<ll>>;using vvb = vector<vb>;
using mpii = map<int,int>;using mpll = map<ll,ll>;
using mpib = map<int,bool>;using mpil = map<int,ll>;
using mpci = map<char,int>;using mpsi = map<string,int>;
using mpivi = map<int,vector<int>>;using mpivl = map<int,vector<ll>>;
using mplvl = map<ll,vl>;
using mpisi = map<int,set<int>>;using mpisl = map<int,set<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YesNo(flag) if(flag){printf("Yes\n");}else{printf("No\n");}
#define Yes cout << "Yes" << '\n';
#define No cout << "No" << '\n';
#define OUT(x) {cout << x << '\n';}
#define OUT_(x) {cout << x << ' ';}
#define all(x) (x).begin(),(x).end()
inline void scan(){}
template<class Head,class... Tail>
inline void scan(Head&head,Tail&... tail){std::cin>>head;scan(tail...);}
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) long long __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T ifloor(T x, T y){return x/y-(x%y ? (x < 0)^(y < 0) : 0);}
template<class T> inline T iceil(T x, T y){return x/y+(x%y ? (x >= 0)^(y < 0) : 0);}
int iinf = 1000000000;
ll linf = 1000000000000000000LL;
mt19937 mt;
int main(){
INT(n);
vl A(n),B(n - 1);
rep(i,n)scan(A[i]);
rep(i,n - 1)scan(B[i]);
sort(all(A));
sort(all(B));
pair<ll,set<ll>> ans = {0,{A[0]}};
rep(i,n - 1){
ans.first += abs(A[i + 1] - B[i]);
}
rep(i,n - 1){
ll pre = abs(A[i + 1] - B[i]);
ll now = abs(A[i] - B[i]);
if(ans.first > ans.first - pre + now){
ans.first = ans.first - pre + now;
ans.second = {A[i + 1]};
}else if(ans.first == ans.first - pre + now){
ans.second.insert(A[i + 1]);
}
}
OUT(ans.second.size());
vl v(all(ans.second));
rep(i,v.size()){
if(i == v.size() - 1){
OUT(v[i]);
}else{
OUT_(v[i]);
}
}
return 0;
}