Submission #961572

# Submission time Handle Problem Language Result Execution time Memory
961572 2024-04-12T08:21:15 Z Unforgettablepl Skyscraper (JOI16_skyscraper) C++17
5 / 100
2000 ms 448 KB
#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

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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2063 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Execution timed out 2063 ms 348 KB Time limit exceeded
12 Halted 0 ms 0 KB -