Submission #1037334

#TimeUsernameProblemLanguageResultExecution timeMemory
1037334RaresFelixShortcut (IOI16_shortcut)C++17
23 / 100
2025 ms600 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ll = long long; using vll = vector<ll>; using ii = pair<int, int>; const ll INF = 1e18; bool ok(int n, vi l, vi d, ll L, int c) { vll sl(n, 0); for (int i = 1; i < sl.size(); ++i) sl[i] = sl[i - 1] + l[i - 1]; for(int a = 0; a < n; ++a) for(int b = a; b < n; ++b) { bool re = true; for(int i = 0; i < n; ++i) { for(int j = i + 1; j < n; ++j) { if(sl[j] - sl[i] + d[i] + d[j] <= L) continue; re &= (abs(sl[i] - sl[a]) + abs(sl[j] - sl[b]) + c + d[i] + d[j]) <= L; } } if(re) return true; } return false; } ll find_shortcut(int n, vi l, vi d, int c) { ll st = 0, dr = INF, mij; while (st < dr) { mij = (st + dr) / 2; if (ok(n, l, d, mij, c)) dr = mij; else st = mij + 1; } return st; }

Compilation message (stderr)

shortcut.cpp: In function 'bool ok(int, vi, vi, ll, int)':
shortcut.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i = 1; i < sl.size(); ++i)
      |                     ~~^~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...