# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82562 | 2018-10-31T12:58:33 Z | thiago4532 | San (COCI17_san) | C++17 | 470 ms | 544 KB |
#include <bits/stdc++.h> #define int int64_t using namespace std; const int maxn = 40; int h[maxn], c[maxn]; int n, k; int32_t main(){ ios::sync_with_stdio(false), cin.tie(0); cin >> n >> k; for(int i=1;i<=n;i++) cin >> h[i] >> c[i]; int ans=0; for(int i=1;i<(1<<n);i++){ vector<int> mark; int num=0; for(int j=1;j<=n;j++) if(i&(1<<(j-1))) mark.push_back(j), num += c[j]; // cout << "{"; // for(int i=0;i<mark.size();i++) // cout << mark[i] << ",}"[i==mark.size()-1]; // cout << "\n"; bool possible = (num >= k); if(!possible) continue; for(int j=0;j<mark.size()-1;j++){ if(h[mark[j+1]] < h[mark[j]]){ possible = false; break; } } if(possible) ans++, ans%=1000000007; } cout << ans << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 465 ms | 464 KB | Output is correct |
2 | Correct | 470 ms | 544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |