Submission #61103

#TimeUsernameProblemLanguageResultExecution timeMemory
61103Eae02Boat (APIO16_boat)C++14
9 / 100
2073 ms8840 KiB
#include <bits/stdc++.h> uint64_t PRIME = 1000000007; std::vector<std::pair<uint64_t, uint64_t>> schools; std::map<uint64_t, uint64_t> memo[500]; uint64_t count(int i, uint64_t min) { if (i >= schools.size()) return 1; auto mIt = memo[i].find(min); if (mIt != memo[i].end()) return mIt->second; uint64_t c = count(i + 1, min); for (uint64_t n = std::max(schools[i].first, min == 0 ? 0 : (min + 1)); n <= schools[i].second; n++) { c = (c + count(i + 1, n)) % PRIME; } memo[i].insert(std::make_pair(min, c)); return c; } int main() { int N; std::cin >> N; schools.resize(N); for (int i = 0; i < N; i++) { std::cin >> schools[i].first; std::cin >> schools[i].second; } std::cout << (count(0, 0) - 1) << std::endl; }

Compilation message (stderr)

boat.cpp: In function 'uint64_t count(int, uint64_t)':
boat.cpp:11:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (i >= schools.size())
      ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...