Submission #638875

#TimeUsernameProblemLanguageResultExecution timeMemory
638875PietraFinancial Report (JOI21_financial)C++14
14 / 100
303 ms2632 KiB
// n valores // qr escolher m p apresentar - a dif de 2 adjs n pode ser maior que d // o ultimo a ser mostrado é pm = n (o ultimo cara smp aparece) // score é o n° vzs q o at eh maior que o pref dele + 1 #include<bits/stdc++.h> #define int long long using namespace std ; // qual o 1o maior p cada cara - esquerda const int inf = 1e13 ; const int maxn = 3e5 + 5 ; int n, mx[maxn], d, v[maxn], esq[maxn] ; int32_t main(){ cin >> n >> d ; for(int i = 1 ; i <= n ; i++) cin >> v[i] ; // esq[1] = 0 ; v[0] = inf ; // for(int i = 2 ; i <= n ; i++){ // esq[i] = i-1 ; // while(v[esq[i]] < v[i]) esq[i] = esq[esq[i]] ; // } int ans = 0 ; int tryy = (1<<7) + (1<<6) + (1<<5) + (1<<4); for(int mask = 0 ; mask < (1<<(n+1)) ; mask++){ if(mask&(1<<0)) continue ; vector<int> vec ; // cout << mask << "\n" ; for(int i = 1 ; i < n + 1 ; i++){ if(mask&(1<<i)) vec.push_back(i) ; } bool ok = 1 ; for(int i = 1 ; i < vec.size() ; i++) if(vec[i] - vec[i-1] > d) ok = 0 ; if(!ok) continue ; for(int i = 0 ; i < vec.size() ; i++){ int fmx = -1 ; for(int j = i - 1 ; j >= 0 ; j--){ if(v[vec[j]] >= v[vec[i]]){fmx = j ; break ;} } esq[i] = fmx ; } int sm = 0 ; for(int i = 0 ; i < vec.size() ; i++) sm += (esq[i]==-1) ; // for(auto a : vec) cout << a << " " ; // cout << "\n" ; // for(int i = 0 ; i < vec.size() ; i++) cout << esq[i] << " " ; // cout << "\n" ; // cout << sm << "\n" ; ans = max(ans, sm) ; } cout << ans << "\n" ; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:40:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |      for(int i = 1 ; i < vec.size() ; i++) if(vec[i] - vec[i-1] > d) ok = 0 ;
      |                      ~~^~~~~~~~~~~~
Main.cpp:42:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |      for(int i = 0 ; i < vec.size() ; i++){
      |                      ~~^~~~~~~~~~~~
Main.cpp:50:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |      for(int i = 0 ; i < vec.size() ; i++) sm += (esq[i]==-1) ;
      |                      ~~^~~~~~~~~~~~
Main.cpp:30:9: warning: unused variable 'tryy' [-Wunused-variable]
   30 |     int tryy = (1<<7) + (1<<6) + (1<<5) + (1<<4);
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...