結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー zuminzumin
提出日時 2021-03-24 23:25:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,268 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 82,852 KB
実行使用メモリ 160,888 KB
最終ジャッジ日時 2023-08-17 22:44:51
合計ジャッジ時間 47,760 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 500 ms
157,364 KB
testcase_01 AC 504 ms
157,424 KB
testcase_02 AC 509 ms
157,448 KB
testcase_03 AC 503 ms
157,408 KB
testcase_04 AC 505 ms
157,356 KB
testcase_05 AC 504 ms
157,332 KB
testcase_06 AC 503 ms
157,344 KB
testcase_07 AC 502 ms
157,368 KB
testcase_08 AC 517 ms
157,472 KB
testcase_09 AC 502 ms
157,468 KB
testcase_10 AC 506 ms
157,644 KB
testcase_11 AC 504 ms
157,572 KB
testcase_12 AC 502 ms
157,380 KB
testcase_13 AC 507 ms
157,400 KB
testcase_14 AC 504 ms
157,336 KB
testcase_15 AC 515 ms
157,380 KB
testcase_16 AC 504 ms
157,404 KB
testcase_17 AC 502 ms
157,372 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 502 ms
157,368 KB
testcase_44 AC 502 ms
157,468 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/iostream:39,
         次から読み込み:  main.cpp:1:
メンバ関数 ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]’ 内,
    inlined from ‘int main()’ at main.cpp:58:11:
/usr/local/gcc7/include/c++/12.2.0/ostream:202:25: 警告: ‘minx’ may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:49:8: 備考: ‘minx’ はここで定義されています
   49 |     ll minx;
      |        ^~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <atcoder/lazysegtree>

using namespace std;
using namespace atcoder;
using ll=long long;

ll op(ll a,ll b){
    if(a>1001001001001001001 || b>1001001001001001001){
        return max(a,b);
    }
    return a+b;
}
ll e() {return 0LL;}
ll mapping(ll F,ll x) {
    if(F>1001001001001001001 || x>1001001001001001001){
        return max(F,x);
    }
    return F+x;
}
ll composition(ll F,ll G) {
    if(F>1001001001001001001 || G>1001001001001001001){
        return max(F,G);
    }
    return F+G;
}
ll id(){ return 0LL;}

int main(){
    ll n,dx=1501001,ans=0;
    cin>>n;

    vector<ll> a(n),b(n);
    lazy_segtree<ll,op,e,ll,mapping,composition,id> s(3001002);

    for(int i=0;i<n;i++) {cin>>a[i];a[i]+=dx;}
    for(int i=0;i<n;i++) cin>>b[i];
    
    for(int i=0;i<n;i++){
        ll ai=a[i],bi=b[i];
        s.apply(0,bi*ai);
        s.apply(1,ai+1,-bi);
        s.apply(ai+1,3001001,bi);
    }
    vector<ll> csum={s.get(0)};
    ll fmin=1001001001001;
    ll minx;
    for(ll i=0;i<3001001;i++){
        csum.push_back(csum[i]+s.get(i+1));
        ll f=csum[i+1];
        if(f<fmin){
            fmin=f;
            minx=i+1-dx;
        }
    }
    cout<<minx<<" "<<fmin<<endl;
    

    return 0;
}
0