Submission #1203503
Source Code Expand
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <string> #include <iostream> #include <stdlib.h> using namespace std; int main() { int n; cin >> n; if(n==1){ cout << 1 << endl; return 0; } long long int a[101] ={}; int i; for(int i=0;i<n;i++) cin >> a[i]; int ans; long long int res[240] = {}; for(ans = n ; ans < 238 ; ans++){ long long int used[240] = {}; int used_n = 0; for(i= ans - n ; i < ans ; i++){ res[i] = a[i - ans + n]; used[used_n] = res[i]; used_n++; } for(i=ans/2 - 1 ; i>=0 ; i--){ if(i >= ans - n){ if(i*2+2 < ans){ if( res[i*2+1] <= res[i] || res[i*2+2] <= res[i]){ break; } }else if(i*2+1 < ans){ if( res[i*2+1] <= res[i] ){ break; } } }else{ if(i >= ans - n){ if(i*2+2 < ans){ if( res[i*2+1] == 0 || res[i*2+2] == 0) break; }else if(i*2+1 < ans){ if( res[i*2+1] == 0 ) break; } } else{ if(i*2+2 < ans){ res[i] = min(res[i*2+1],res[i*2+2]) - 1; while( res[i]>=0 ){ bool ok = true; for(int k=0;k<used_n;k++){ if(used[k] == res[i]){ ok = false; } } if(!ok) res[i]--; else break; } if(res[i] == -1) break; used[used_n] = res[i]; used_n++; } else{ res[i] = res[i*2+1] -1; while( res[i]>=0 ){ bool ok = true; for(int k=0;k<used_n;k++){ if(used[k] == res[i]){ ok = false; } } if(!ok) res[i]--; else break; } if(res[i] =< -1) break; used[used_n] = res[i]; used_n++; } } } if(i == 0){ cout << ans << endl; return 0; } } } cout << -1 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 壊れかけのヒープ |
User | tsunenarazu |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2392 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:106:24: error: expected primary-expression before ‘<’ token if(res[i] =< -1) ^