# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
288028 | 2020-09-01T08:00:00 Z | 문홍윤(#5789) | Skyscraper (JOI16_skyscraper) | C++17 | 3 ms | 256 KB |
#include <bits/stdc++.h> #define eb emplace_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define svec(x) sort(x.begin(), x.end()) #define press(x) x.erase(unique(x.begin(), x.end()), x.end()) using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; typedef pair<int, LL> pil; typedef pair<LL, int> pli; const LL llinf=2e18; const int inf=1e9; int n, l, ans; int arr[10]; bool poss(vector<int> vc){ int len=0; for(int i=1; i<vc.size(); i++){ len+=abs(arr[vc[i]]-arr[vc[i-1]]); } return len<=l; } int main(){ scanf("%d %d", &n, &l); if(n==1)return !printf("1"); for(int i=1; i<=n; i++)scanf("%d", &arr[i]); vector<int> vc; for(int i=1; i<=n; i++)vc.eb(i); if(poss(vc))ans++; while(next_permutation(all(vc))){ if(poss(vc))ans++; } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Correct | 3 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 256 KB | Output is correct |
9 | Correct | 3 ms | 256 KB | Output is correct |
10 | Correct | 3 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Correct | 3 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 256 KB | Output is correct |
9 | Correct | 3 ms | 256 KB | Output is correct |
10 | Correct | 3 ms | 256 KB | Output is correct |
11 | Incorrect | 1 ms | 256 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |