結果
| 問題 |
No.107 モンスター
|
| コンテスト | |
| ユーザー |
shimarut
|
| 提出日時 | 2021-02-05 12:34:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 2,442 bytes |
| コンパイル時間 | 1,066 ms |
| コンパイル使用メモリ | 111,168 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 03:50:22 |
| 合計ジャッジ時間 | 1,973 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <regex>
#include <fstream>
#include <array>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
////using mint = modint1000000007;
//using mint = modint998244353;
////using mint = modint;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#pragma region UnionFind
struct UnionFind
{
vector<int> par;
UnionFind(int n) : par(n, -1) {}
void init(int n) { par.assign(n, -1); }
int root(int x)
{
if (par[x] < 0) return x;
else return par[x] = root(par[x]);
}
bool issame(int x, int y)
{
return root(x) == root(y);
}
bool merge(int x, int y)
{
x = root(x); y = root(y);
if (x == y) return false;
if (par[x] > par[y]) swap(x, y);
par[x] += par[y];
par[y] = x;
return true;
}
int size(int x)
{
return -par[root(x)];
}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
if (b == 0)return a;
return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
#pragma endregion
bool out(int x, int y, int h, int w)
{
if (x < 0 || h <= x || y < 0 || w <= y)return true;
else return false;
}
#pragma endregion
int main()
{
int n; cin >> n;
vi d(n); rep(i, n)cin >> d[i];
vi dp(1 << n);
dp[0] = 100;
rep(S, 1 << n)
{
if (dp[S] <= 0)continue;
int level = 1;
rep(i, n)if (S&(1 << i) && d[i] < 0)++level;
rep(i, n)
{
if (S&(1 << i))continue;
chmax(dp[S + (1 << i)], min(100 * level, dp[S] + d[i]));
}
}
cout << dp[(1 << n) - 1] << endl;
}
shimarut