# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173078 | emil_physmath | 은행 (IZhO14_bank) | C++17 | 1073 ms | 79432 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef double ldouble;
typedef long long llong;
typedef unsigned int uint;
vector<uint> sumup[1001];
int sum[1 << 20], bits[1 << 20];
bool IsSet(uint mask, uint i)
{
return mask & (1 << i);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> a(n);
for (int& x: a)
cin >> x;
vector<int> b(m);
for (int& x: b)
cin >> x;
for (uint mask = 0; mask < (1 << m); ++mask)
{
int curSum = 0, curBits = 0;
for (int i = 0; i < m; ++i)
if (IsSet(mask, i))
{
++curBits;
curSum += b[i];
}
if (curSum <= 1000)
sumup[curSum].push_back(mask);
sum[mask] = curSum;
bits[mask] = curBits;
}
vector<uint> possLeft;
/* for (uint mask = 0; mask < (1 << m); ++mask)
possLeft.push_back(mask); */
possLeft.push_back((1 << m) - 1);
vector<uint> temp;
for (int i = 0; i < n; ++i)
{
temp.clear();
// cerr << possLeft.size() << endl;
for (uint left: possLeft)
for (uint mask: sumup[a[i]])
{
// cerr << "get " << a[i] << " with " << mask << endl;
if ((mask & left) == mask)
temp.push_back(left ^ mask);
}
possLeft.clear();
sort(temp.begin(), temp.end());
for (int i = 0; i < temp.size(); ++i)
if (!i || temp[i] != temp[i - 1])
possLeft.push_back(temp[i]);
}
// cerr << possLeft.size() << endl;
cout << (possLeft.size() ? "YES" : "NO");
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |