# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758054 | 2023-06-14T05:58:21 Z | vjudge1 | Money (IZhO17_money) | C++17 | 1 ms | 324 KB |
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <fstream> #define endl '\n' #define int long long #define mod 998244353 using namespace std; int a[1000001]; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, finn = 1e18; cin >> n; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < (1 << n); i++){ vector<vector<int>>d; vector<int>p; int ans = 0; for(int j = 0; j < n; j++){ if(i & (1 << j)){ p.push_back(a[j]); d.push_back(p); p.clear(); }else{ p.push_back(a[j]); } } if(p.size()) d.push_back(p); ans = d.size(); deque<int>y; for(int j = 0; j < d.size(); j++){ if(y.empty()){ for(int k = 0; k < d[j].size(); k++) y.push_back(d[j][k]); }else{ deque<int>w; for(int k = 0; k < y.size(); k++){ if(y.front() <= d[j][0]){ w.push_back(y.front()); y.pop_front(); }else{ break; } } for(int k = d[j].size() - 1; k >= 0; k--){ y.push_front(d[j][k]); } while(w.size()){ y.push_front(w.front()); w.pop_front(); } } } int bad = 0; for(int j = 1; j < y.size(); j++){ if(y[j] < y[j - 1]) bad = 1; } if(!bad) finn = min(finn, ans); } cout << finn; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 324 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 324 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 324 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 324 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |