# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
473646 |
2021-09-15T19:08:39 Z |
_L__ |
San (COCI17_san) |
C++17 |
|
1000 ms |
10664 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);
vector<pair<ll, ll>> v;
for(int i = 0; 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});
}
unordered_map<ll, vector<ll>> mp;
for(int i = 0; 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;}
}
if(valid) mp[fi].push_back(sum);
}
ll ans = 0;
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 |
1 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 |
789 ms |
1608 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
2636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
10664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |