# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200932 | SamAnd | San (COCI17_san) | C++17 | 91 ms | 7652 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 44;
int n;
long long k;
pair<int, int> a[N];
vector<long long> v[N];
int main()
{
scanf("%d%lld", &n, &k);
for (int i = 0; i < n; ++i)
scanf("%d%d", &a[i].first, &a[i].second);
for (int i = 0; i < n / 2; ++i)
{
for (int j = 0; j < i; ++j)
{
if (a[j].first <= a[i].first)
{
for (int k = 0; k < v[j].size(); ++k)
v[i].push_back(v[j][k] + a[i].second);
}
}
v[i].push_back(a[i].second);
}
for (int i = n - 1; i >= n / 2; --i)
{
for (int j = i + 1; j < n; ++j)
{
if (a[i].first <= a[j].first)
{
for (int k = 0; k < v[j].size(); ++k)
v[i].push_back(v[j][k] + a[i].second);
}
}
v[i].push_back(a[i].second);
}
for (int i = 0; i < n; ++i)
sort(v[i].begin(), v[i].end());
long long ans = 0;
for (int i = 0; i < n / 2; ++i)
{
for (int j = n / 2; j < n; ++j)
{
if (a[i].first <= a[j].first)
{
int k2 = v[j].size();
for (int k1 = 0; k1 < v[i].size(); ++k1)
{
while (k2 != 0)
{
if (v[j][k2 - 1] + v[i][k1] >= k)
--k2;
else
break;
}
ans += (v[j].size() - k2);
}
}
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < v[i].size(); ++j)
{
if (v[i][j] >= k)
++ans;
}
}
printf("%lld\n", ans);
return 0;
}
Compilation message (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |