結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 323 ms
157,368 KB
testcase_01 AC 321 ms
157,392 KB
testcase_02 AC 314 ms
157,476 KB
testcase_03 AC 324 ms
157,440 KB
testcase_04 AC 322 ms
157,416 KB
testcase_05 AC 321 ms
157,368 KB
testcase_06 AC 322 ms
157,564 KB
testcase_07 AC 325 ms
157,620 KB
testcase_08 AC 327 ms
157,344 KB
testcase_09 AC 322 ms
157,476 KB
testcase_10 AC 328 ms
157,344 KB
testcase_11 AC 323 ms
157,364 KB
testcase_12 AC 321 ms
157,656 KB
testcase_13 AC 326 ms
157,628 KB
testcase_14 AC 324 ms
157,448 KB
testcase_15 AC 327 ms
157,472 KB
testcase_16 AC 328 ms
157,652 KB
testcase_17 AC 325 ms
157,344 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 RE -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 332 ms
157,492 KB
testcase_44 AC 330 ms
157,564 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:43: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:34:8: 備考: ‘minx’ はここで定義されています
   34 |     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) {return a+b;}
ll e() {return 0LL;}
ll mapping(ll F,ll x) {return F+x;}
ll composition(ll F,ll G) {return F+G;}
ll id(){ return 0LL;}

int main(){
    ll n,dx=2001001,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