結果
| 問題 | No.1251 絶対に間違ってはいけない最小化問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-07 11:22:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,696 bytes |
| コンパイル時間 | 1,365 ms |
| コンパイル使用メモリ | 170,920 KB |
| 実行使用メモリ | 13,760 KB |
| 最終ジャッジ日時 | 2024-09-17 13:50:54 |
| 合計ジャッジ時間 | 8,183 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | WA * 15 TLE * 1 -- * 26 |
コンパイルメッセージ
main.cpp:12: warning: "ONLINE_JUDGE" redefined
12 | #define ONLINE_JUDGE
|
<command-line>: note: this is the location of the previous definition
main.cpp: In function 'std::istream& IN(Ts& ...)':
main.cpp:31:57: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
31 | std::istream& IN(Ts&... xs){ return (std::cin >> ... >> xs); }
| ^~
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 998244353;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
ostream &operator<<(ostream &o, const string &obj) {o << "\""; o << obj.c_str(); o << "\""; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif
template <typename... Ts>
std::istream& IN(Ts&... xs){ return (std::cin >> ... >> xs); }
#define repr(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
ll f(ll x, vector<ll>& b, vector<ll>& a){
ll ans = 0;
rep(i, b.size()){
ans += b[i]*abs(x - a[i]);
}
return ans;
}
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
IN(n);
vector<ll> a(n),b(n);
rep(i, n) cin >> a[i];
rep(i, n) cin >> b[i];
ll a_min = a[0]; ll a_max = a[0];
for(auto&& z : a){
a_min = min(a_min, z);
a_max = max(a_max, z);
}
print(a_min, a_max)
ll ans = a_max*n;
ll x = 1;
repr(i, a_min, a_max){
ll ans_i = f(i,b,a);
if(ans_i < ans){
ans = ans_i;
x = i;
}
}
cout << x << " " << ans << endl;
return 0;
}