//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long
typedef pair<int, int> T;
const int oo = 1e18, oo2 = 1e9+7, K = 30;
const int mod = 998244353;
void solve(){
int n, m; cin >> n >> m;
vector<T>a(n);
for (int i = 0; i<n; i++){
cin >> a[i].second >> a[i].first;
}
sort(a.begin(), a.end());
vector<int>b(m);
for (auto &x: b) cin >> x;
//n > m
while ((int)b.size() < n) b.emplace_back(-oo);
sort(b.begin(), b.end());
//m > n
reverse(b.begin(), b.end());
while ((int)b.size() > n) b.pop_back();
reverse(b.begin(), b.end());
debug(b);
assert((int)b.size() == n);
vector<int>p(n);
iota(p.begin(), p.end(), 0);
debug(a);
int ans = 0;
do {
int k = 0;
vector<int>tab;
for (auto i: p){
//kty obraz z i-ta ramka
if (b[i] >= a[k].second){
tab.emplace_back(b[i]);
}
k++;
}
if (is_sorted(tab.begin(), tab.end())){
ans = max(ans, (int)tab.size());
}
} while (next_permutation(p.begin(), p.end()));
cout << ans << "\n";
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while (t--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
440 ms |
296 KB |
Output is correct |
3 |
Correct |
483 ms |
296 KB |
Output is correct |
4 |
Correct |
51 ms |
212 KB |
Output is correct |
5 |
Correct |
107 ms |
296 KB |
Output is correct |
6 |
Correct |
510 ms |
292 KB |
Output is correct |
7 |
Correct |
473 ms |
296 KB |
Output is correct |
8 |
Correct |
542 ms |
292 KB |
Output is correct |
9 |
Correct |
51 ms |
296 KB |
Output is correct |
10 |
Correct |
192 ms |
292 KB |
Output is correct |
11 |
Correct |
566 ms |
212 KB |
Output is correct |
12 |
Correct |
326 ms |
300 KB |
Output is correct |
13 |
Correct |
474 ms |
300 KB |
Output is correct |
14 |
Correct |
68 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
334 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
432 ms |
300 KB |
Output is correct |
19 |
Correct |
303 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
440 ms |
296 KB |
Output is correct |
3 |
Correct |
483 ms |
296 KB |
Output is correct |
4 |
Correct |
51 ms |
212 KB |
Output is correct |
5 |
Correct |
107 ms |
296 KB |
Output is correct |
6 |
Correct |
510 ms |
292 KB |
Output is correct |
7 |
Correct |
473 ms |
296 KB |
Output is correct |
8 |
Correct |
542 ms |
292 KB |
Output is correct |
9 |
Correct |
51 ms |
296 KB |
Output is correct |
10 |
Correct |
192 ms |
292 KB |
Output is correct |
11 |
Correct |
566 ms |
212 KB |
Output is correct |
12 |
Correct |
326 ms |
300 KB |
Output is correct |
13 |
Correct |
474 ms |
300 KB |
Output is correct |
14 |
Correct |
68 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
334 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
432 ms |
300 KB |
Output is correct |
19 |
Correct |
303 ms |
296 KB |
Output is correct |
20 |
Execution timed out |
1085 ms |
340 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
440 ms |
296 KB |
Output is correct |
3 |
Correct |
483 ms |
296 KB |
Output is correct |
4 |
Correct |
51 ms |
212 KB |
Output is correct |
5 |
Correct |
107 ms |
296 KB |
Output is correct |
6 |
Correct |
510 ms |
292 KB |
Output is correct |
7 |
Correct |
473 ms |
296 KB |
Output is correct |
8 |
Correct |
542 ms |
292 KB |
Output is correct |
9 |
Correct |
51 ms |
296 KB |
Output is correct |
10 |
Correct |
192 ms |
292 KB |
Output is correct |
11 |
Correct |
566 ms |
212 KB |
Output is correct |
12 |
Correct |
326 ms |
300 KB |
Output is correct |
13 |
Correct |
474 ms |
300 KB |
Output is correct |
14 |
Correct |
68 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
334 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
432 ms |
300 KB |
Output is correct |
19 |
Correct |
303 ms |
296 KB |
Output is correct |
20 |
Execution timed out |
1085 ms |
340 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |