# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
37183 | 2017-12-22T09:46:13 Z | Ulugbek_Abdimanabov | Money (IZhO17_money) | C++14 | 0 ms | 3188 KB |
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <cstring> #include <map> #include <cstdlib> #include <ctime> #include <cassert> #include <bitset> #define f first #define s second #define ll long long #define ull unsigned long long #define mp make_pair #define pb push_back #define vi vector <int> #define ld long double #define pii pair<int, int> #define y1 sda using namespace std; const int N = int(3e5), mod = int(1e9) + 7; int n, a[N]; bool check(int l,int r) { for(int i = l + 1; i <= r; i++) { if(a[i] < a[i - 1]) return 0; } for(int i = 0; i < l; i++) { if(a[i] > a[l] && a[i] < a[r]) return 0; } return 1; } int main () { freopen("money.in","r", stdin); freopen("money.out","w", stdout); cin >> n; for(int i = 0; i < n; i++) { cin >> a[i]; } int ans = N; for(int mask = 0; mask < (1<<n); mask++) { if(!(mask & 1<<(n - 1))) continue; int last = 0; bool ok = 1; for(int i = 0; i < n; i++) { if(mask & (1<<i)) { if(!check(last, i)) ok = 0; last = i + 1; } } if(ok) ans = min(ans, __builtin_popcount(mask)); } cout << ans << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 3188 KB | Execution killed because of forbidden syscall [unknown syscall - gap in table] (292) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 3188 KB | Execution killed because of forbidden syscall [unknown syscall - gap in table] (292) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 3188 KB | Execution killed because of forbidden syscall [unknown syscall - gap in table] (292) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 3188 KB | Execution killed because of forbidden syscall [unknown syscall - gap in table] (292) |
2 | Halted | 0 ms | 0 KB | - |