# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95945 | 2019-02-04T15:15:02 Z | Retro3014 | Skyscraper (JOI16_skyscraper) | C++17 | 18 ms | 376 KB |
#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> using namespace std; typedef long long ll; #define MAX_N 100 #define DIV 1000000007LL int N; vector<int> v; ll ans; bool chk[MAX_N+1]; int arr[MAX_N+1]; ll L, L2; int zero(int x){ return (x>0?x:-x); } void dfs(int x){ if(x==N){ if(L>=L2){ ans++; return; } }else{ for(int i=0; i<N; i++){ if(!chk[i]){ arr[x] = i; chk[i] = true; if(x!=0){ L2+=(ll)zero(v[arr[x]]-v[arr[x-1]]); } dfs(x+1); chk[i] = false; if(x!=0){ L2-=(ll)zero(v[arr[x]]-v[arr[x-1]]); } arr[x] = 0; } } } } void solve1(){ dfs(0); return; } void solve2(){ return; } int main(){ scanf("%d%lld", &N, &L); for(int i=0; i<N; i++){ int x; scanf("%d", &x); v.push_back(x); } if(N<=8){ solve1(); }else{ solve2(); } printf("%lld", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Correct | 4 ms | 376 KB | Output is correct |
7 | Correct | 18 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Correct | 4 ms | 376 KB | Output is correct |
7 | Correct | 18 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Incorrect | 2 ms | 256 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |