#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
632 KB |
Output is correct |
2 |
Correct |
3623 ms |
1348 KB |
Output is correct |
3 |
Correct |
444 ms |
808 KB |
Output is correct |
4 |
Execution timed out |
5043 ms |
1204 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5066 ms |
1788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5078 ms |
2660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5060 ms |
4140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |