結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー KKT89KKT89
提出日時 2020-10-10 04:06:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 579 bytes
コンパイル時間 3,080 ms
コンパイル使用メモリ 204,992 KB
実行使用メモリ 6,420 KB
最終ジャッジ日時 2023-09-27 21:02:29
合計ジャッジ時間 16,095 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 55 ms
5,956 KB
testcase_19 AC 52 ms
6,028 KB
testcase_20 AC 30 ms
4,748 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 33 ms
4,944 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 43 ms
5,400 KB
testcase_25 AC 32 ms
4,828 KB
testcase_26 AC 13 ms
4,376 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 59 ms
6,172 KB
testcase_29 AC 58 ms
6,312 KB
testcase_30 AC 60 ms
6,144 KB
testcase_31 AC 58 ms
6,084 KB
testcase_32 AC 59 ms
6,420 KB
testcase_33 AC 59 ms
6,092 KB
testcase_34 AC 57 ms
6,168 KB
testcase_35 AC 56 ms
6,224 KB
testcase_36 AC 59 ms
6,204 KB
testcase_37 AC 59 ms
6,100 KB
testcase_38 AC 56 ms
6,084 KB
testcase_39 AC 57 ms
6,096 KB
testcase_40 AC 56 ms
6,144 KB
testcase_41 AC 58 ms
6,208 KB
testcase_42 AC 59 ms
6,204 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<pair<ll,ll>> v(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin >> v[i].first;
	}
	for(int i=0;i<n;i++){
		cin >> v[i].second;
		sum+=v[i].second;
	}
	sort(v.begin(), v.end());
	sum=(sum+1)/2;
	for(int i=0;i<n;i++){
		if(sum>=v[i].second){
			sum-=v[i].second;
		}
		else{
			sum=v[i].first;
			break;
		}
	}
	ll res=0;
	for(int i=0;i<n;i++){
		res+=v[i].second*abs(sum-v[i].first);
	}
	cout << sum << " " << res << endl;
}
0