Submission #241252


Source Code Expand

Copy
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<25;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;

int dp[4][256];

int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i = 0; i < n; i++){
		cin>>d[i];
	}

	int sum = 0;
	for(int i = 0; i < n; i++){
		sum += d[i];
	}

	int res = INF;
	for(int i = 0; i < 1<<n; i++){
		int r = 0;
		for(int j = 0; j < n; j++){
			if(i&(1<<j)) r += d[j];
		}
		res = min(res, max(r, sum-r));
	}
	cout<<res<<endl;
	return 0;
}

Submission Info

Submission Time
Task A - 高橋君とお肉
User Lepton
Language C++ (G++ 4.6.4)
Score 100
Code Size 950 Byte
Status
Exec Time 35 ms
Memory 1172 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0-sample-01.txt, subtask0-sample-02.txt, subtask0-sample-03.txt
All 100 / 100 subtask0-sample-01.txt, subtask0-sample-02.txt, subtask0-sample-03.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt
Case Name Status Exec Time Memory
subtask0-sample-01.txt 30 ms 1048 KB
subtask0-sample-02.txt 29 ms 1104 KB
subtask0-sample-03.txt 29 ms 1048 KB
subtask1-01.txt 30 ms 1056 KB
subtask1-02.txt 31 ms 1172 KB
subtask1-03.txt 35 ms 1056 KB
subtask1-04.txt 29 ms 1116 KB
subtask1-05.txt 29 ms 1112 KB
subtask1-06.txt 29 ms 1104 KB
subtask1-07.txt 31 ms 1120 KB
subtask1-08.txt 30 ms 1048 KB
subtask1-09.txt 29 ms 1044 KB
subtask1-10.txt 29 ms 1112 KB
subtask1-11.txt 31 ms 1096 KB
subtask1-12.txt 30 ms 1124 KB
subtask1-13.txt 32 ms 1104 KB
subtask1-14.txt 33 ms 1044 KB
subtask1-15.txt 31 ms 1104 KB
subtask1-16.txt 31 ms 1048 KB