#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
int len, n, temp[N];
pair<int, int> tim[N];
map<pair<int, int>, bool> mp;
bool is_clique(int b){
for (int i = 1; i < b; i++)
for (int j = i + 1; j < b; j++)
if (!mp[{temp[i], temp[j]}])
return false;
return true;
}
int maxclique(int node, int l){
int ans = 0;
for(int i = node + 1; i <= n; ++i){
temp[l] = i;
if(is_clique(l + 1)){
ans = max(ans, l);
ans = max(ans, maxclique(i, l + 1));
}
}
return ans;
}
void solve(){
cin >> len >> n;
for(int i = 1; i <= n; ++i)
cin >> tim[i].first >> tim[i].second;
sort(tim + 1, tim + n + 1);
for(int i = 1; i <= n; ++i){
long double cur = (ld) ((ld) len/(ld) tim[i].second) + tim[i].first;
for(int j = i + 1; j <= n; ++j){
if(cur > ((ld) ((ld) len / (ld) tim[j].second) + tim[j].first)){
mp[{i, j}] = true;
mp[{j, i}] = true;
}
}
}
cout << maxclique(0, 1) << "\n";
}
int main(){
fast;
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
356 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
652 KB |
Output is correct |
2 |
Correct |
3609 ms |
1244 KB |
Output is correct |
3 |
Correct |
435 ms |
712 KB |
Output is correct |
4 |
Execution timed out |
5087 ms |
1112 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5057 ms |
1784 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5070 ms |
2324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5093 ms |
4144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |