Submission #477817

#TimeUsernameProblemLanguageResultExecution timeMemory
477817sumit_kk10Walking (NOI12_walking)C++14
3 / 25
5093 ms4144 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...