結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー chocorusk
提出日時 2020-10-09 21:27:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,008 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 122,748 KB
最終ジャッジ日時 2025-01-15 03:56:00
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
using ll=long long;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    ll a[200010], b[200020];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    ll sb=0;
    for(int i=0; i<n; i++){
        cin>>b[i];
        sb+=b[i];
    }
    ll s=0;
    ll a0=a[0];
    for(int i=0; i<n; i++){
        s+=b[i];
        if(-sb+2*s>=0){
            a0=a[i];break;
        }
    }
    cout<<a0<<" ";
    ll ans=0;
    for(int i=0; i<n; i++){
        ans+=b[i]*abs(a[i]-a0);
    }
    cout<<ans<<endl;
    return 0;
}
0