# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
473648 |
2021-09-15T19:15:08 Z |
_L__ |
San (COCI17_san) |
C++17 |
|
1000 ms |
10720 KB |
// This code is written by _L__
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7, N = 5e5+13, inf = 1e11;
const ld E = 1e-6;
#define ff first
#define ss second
int main(void){
F_word;
ll n, k; cin >> n >> k; ll h1[n/2], h2[n-(n/2)], c1[n/2], c2[n-(n/2)];
for(int i = 0; i < n; ++i){
if(i < (n/2)) cin >> h1[i] >> c1[i];
else cin >> h2[i-(n/2)] >> c2[i-(n/2)];
}
int q1 = n/2, q2 = n-(n/2);
ll ans = 0;
vector<pair<ll, ll>> v;
for(int i = 1; i < (1<<q1); ++i){
bool valid = 1; ll last = 0, sum = 0;
for(int j = 0; j < q1; ++j){
if(!(i&(1<<j))) continue;
if(h1[j] >= last){sum += c1[j]; last = h1[j];}
else{valid = 0; break;}
}
if(valid) v.push_back({last, sum});
ans += (sum>=k);
}
sort(v.begin(), v.end());
map<ll, vector<ll>> mp;
for(int i = 1; i < (1<<q2); ++i){
bool valid = 1; ll last = 0, fi = inf, sum = 0;
for(int j = 0; j < (q2); ++j){
if(!(i&(1<<j)))continue;
if(fi == inf) fi = h2[j];
if(h2[j] >= last){last = h2[j]; sum += c2[j];}
else{valid = 0; break;}
ans += (sum >= k);
}
if(valid) mp[fi].push_back(sum);
}
for(auto i: mp) sort(i.ss.begin(), i.ss.end());
for(auto u: v){
for(auto i: mp){
if(i.ff >= u.ff){
ll z = lower_bound(i.ss.begin(), i.ss.end(), max(k-u.ss, 0ll))-i.ss.begin();
ans += max((ll)i.ss.size()-z, 0ll);
}
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
807 ms |
1480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
2620 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
10720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |