Submission #961572

#TimeUsernameProblemLanguageResultExecution timeMemory
961572UnforgettableplSkyscraper (JOI16_skyscraper)C++17
5 / 100
2063 ms448 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int modulo = 1e9+7; bool check(int L,vector<int> &arr){ for(int i=1;i<arr.size();i++){ L-=abs(arr[i]-arr[i-1]); } return 0<=L; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,l; cin >> n >> l; vector<int> arr(n); for(int&i:arr)cin>>i; sort(arr.begin(),arr.end()); int ans = 0; do { if(check(l,arr))ans++; } while(next_permutation(arr.begin(),arr.end())); cout << ans%modulo << '\n'; }

Compilation message (stderr)

skyscraper.cpp: In function 'bool check(long long int, std::vector<long long int>&)':
skyscraper.cpp:9:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=1;i<arr.size();i++){
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...