Submission #592430

#TimeUsernameProblemLanguageResultExecution timeMemory
592430webA Huge Tower (CEOI10_tower)C++17
90 / 100
1087 ms34196 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; constexpr long long mod = 1000000009; long long numWaysTower(vector<long>& blocks, int index,const long D) { if(index == blocks.size()) return 1; else { long long numWaysPrev = numWaysTower(blocks, index+1,D); long long validPositions =1; for(int i = index+1; i < blocks.size(); ++i) { if(blocks[index] <= blocks[i] + D) validPositions++; else break; } return ((validPositions%mod)*(numWaysPrev%mod))%mod; } } int main() { long N,D;cin>>N>>D; vector<long> blocks(N); for(int i =0; i<N; ++i) cin>>blocks[i]; sort(blocks.rbegin(), blocks.rend()); cout<<numWaysTower(blocks, 0, D)<<endl; return 0; }

Compilation message (stderr)

tower.cpp: In function 'long long int numWaysTower(std::vector<long int>&, int, long int)':
tower.cpp:10:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     if(index == blocks.size())
      |        ~~~~~~^~~~~~~~~~~~~~~~
tower.cpp:16:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int i = index+1; i < blocks.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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...