Submission #750732

#TimeUsernameProblemLanguageResultExecution timeMemory
750732Sami_MassahCollecting Stamps 3 (JOI20_ho_t3)C++17
0 / 100
2077 ms212 KiB
#include <bits/stdc++.h> using namespace std; const long long maxn = 200 + 12, inf = 1e9 + 12; int n, L, dist[maxn], t[maxn]; vector <int> pos, anses; int get_dist(int a, int b){ if(a > b) swap(a, b); int x = abs(a - b); x = min(x, L - b + a); return x; } int main(){ cin >> n >> L; // n = 10; // L= 100; for(int i = 0; i < n; i++){ cin >> dist[i]; // dist[i] = rand() % (L - 1) + 1; } for(int i = 0; i < n; i++){ // t[i] = rand() % (100); cin >> t[i]; } pos.clear(); for(int i = 0; i < n; i++) pos.push_back(i); int ans = 0; int now = 0, nat = 0, st = 0; for(int i: pos){ now += get_dist(dist[i], st); st = dist[i]; if(now <= t[i]) nat += 1; } ans = max(ans, nat); while(next_permutation(pos.begin(), pos.end())){ int now = 0, nat = 0, st = 0; for(int i: pos){ now += get_dist(dist[i], st); st = dist[i]; if(now <= t[i]) nat += 1; } ans = max(ans, nat); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...