# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
584343 | 2022-06-27T08:32:59 Z | drdilyor | Skyscraper (JOI16_skyscraper) | C++17 | 2000 ms | 212 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #ifdef ONPC #include "t_debug.cpp" #else #define debug(...) 42 #endif #define allit(a) (a).begin(), (a).end() #define sz(a) ((int) (a).size()) #define cut(s) {cout << s << '\n'; return 0;} using namespace std; using ll = long long; using vi = vector<int>; namespace pd = __gnu_pbds; template<typename K> using ordered_set = pd::tree<K, pd::null_type, less<K>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>; template<typename... T> using hash_table = pd::gp_hash_table<T...>; const int INF = 1e9; const ll INFL = 1e18; const int N = 1e5; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937 rng(RANDOM); int solve() { int n, l; cin >> n >> l; vi a(n); for (auto& i : a) cin >> i; vi cur, taken(n, 0); ll res = 0; function<void()> brute = [&]() { if (cur.size() == n) { int cost = 0; for (int i = 1; i < n; i++) { cost += abs(cur[i] - cur[i-1]); } debug(cur, cost); if (cost <= l) res++; } else { for (int i = 0; i < n; i++) { if (!taken[i]) { taken[i] = 1; cur.push_back(a[i]); brute(); cur.pop_back(); taken[i] = 0; } } } }; brute(); cout << res << '\n'; return 0; } signed main() { cin.tie(0)->sync_with_stdio(0); int t = 1; //cin >> t; while (t-- && cin) { if (solve()) break; #ifdef ONPC cout << "____________________" << endl; #endif } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 3 ms | 212 KB | Output is correct |
6 | Correct | 3 ms | 212 KB | Output is correct |
7 | Correct | 3 ms | 212 KB | Output is correct |
8 | Correct | 3 ms | 212 KB | Output is correct |
9 | Correct | 3 ms | 212 KB | Output is correct |
10 | Correct | 3 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2085 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 3 ms | 212 KB | Output is correct |
6 | Correct | 3 ms | 212 KB | Output is correct |
7 | Correct | 3 ms | 212 KB | Output is correct |
8 | Correct | 3 ms | 212 KB | Output is correct |
9 | Correct | 3 ms | 212 KB | Output is correct |
10 | Correct | 3 ms | 212 KB | Output is correct |
11 | Execution timed out | 2085 ms | 212 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |