提出 #58437915


ソースコード 拡げる

//yukicoder@cpp17

#include <iostream>
#include <iomanip>

#include <algorithm>

#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

#include <random>

#include <bitset>

#include <complex>

#include <utility>

#include <numeric>

#include <functional>


using namespace std;
using ll = long long;
using P = pair<ll,ll>;


const ll MOD = 998244353;
const ll MODx = 1000000007;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62LL)-1;
const double EPS = (1e-10);


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};


template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }
 
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/

/* comment outed because can cause bugs
__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
*/
int main(){
  int n;cin>>n;
  int ans = 0;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];ans += A[i];
  }
  for(int i = 0; (1<<n) > i; i++){
    int x = 0;
    int y = 0;
    for(int j = 0; n > j; j++){
      if(i & (1<<j))x+=A[j];
      else y += A[j];
    }
    ans = min(ans, max(x,y));
  }
  cout << ans << endl;
  return 0;
}

提出情報

提出日時
問題 C - Separated Lunch
ユーザ CleyL
言語 C++ 20 (gcc 12.2)
得点 300
コード長 1841 Byte
結果 AC
実行時間 65 ms
メモリ 3664 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 30
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 3532 KiB
example_01.txt AC 1 ms 3532 KiB
example_02.txt AC 1 ms 3464 KiB
hand_00.txt AC 61 ms 3476 KiB
hand_01.txt AC 65 ms 3592 KiB
hand_02.txt AC 65 ms 3520 KiB
hand_03.txt AC 1 ms 3592 KiB
hand_04.txt AC 62 ms 3588 KiB
hand_05.txt AC 61 ms 3524 KiB
random_00.txt AC 16 ms 3476 KiB
random_01.txt AC 16 ms 3524 KiB
random_02.txt AC 32 ms 3464 KiB
random_03.txt AC 31 ms 3520 KiB
random_04.txt AC 63 ms 3532 KiB
random_05.txt AC 31 ms 3528 KiB
random_06.txt AC 16 ms 3488 KiB
random_07.txt AC 31 ms 3360 KiB
random_08.txt AC 63 ms 3476 KiB
random_09.txt AC 16 ms 3520 KiB
random_10.txt AC 16 ms 3508 KiB
random_11.txt AC 31 ms 3484 KiB
random_12.txt AC 31 ms 3460 KiB
random_13.txt AC 62 ms 3472 KiB
random_14.txt AC 62 ms 3524 KiB
random_15.txt AC 63 ms 3524 KiB
random_16.txt AC 30 ms 3536 KiB
random_17.txt AC 33 ms 3664 KiB
random_18.txt AC 64 ms 3516 KiB
random_19.txt AC 33 ms 3528 KiB
random_20.txt AC 63 ms 3440 KiB