제출 #638347

#제출 시각아이디문제언어결과실행 시간메모리
638347LeticiaFCSFinancial Report (JOI21_financial)C++17
0 / 100
4049 ms7848 KiB
#include "bits/stdc++.h" #define st first #define nd second using lint = int64_t; constexpr int MOD = int(1e9) + 7; constexpr int INF = 0x3f3f3f3f; constexpr int NINF = 0xcfcfcfcf; constexpr lint LINF = 0x3f3f3f3f3f3f3f3f; const long double PI = acosl(-1.0); // Returns -1 if a < b, 0 if a = b and 1 if a > b. int cmp_double(double a, double b = 0, double eps = 1e-9) { return a + eps > b ? b + eps > a ? 0 : 1 : -1; } using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, d; cin>>n>>d; vector<int> a(n+1); vector<int> dp(n+1, 0); //dp[i] <-- max se i é o último e inc sub map<int,vector<int>> idOfVal; for(int i=1; i<=n; i++){ cin>>a[i]; idOfVal[a[i]].push_back(i); } for(auto &[x, ids]: idOfVal){ reverse(ids.begin(), ids.end()); for(int id: ids){ //cerr<<"id "<<id<<"\n"; dp[id] = 1; for(int j = max(1, id-d); j<id; j++){ dp[id] = max(dp[id], 1 + dp[j]); } //cerr<<"dp["<<id<<"] = "<<dp[id]<<"\n"; } } cout<<*max_element(dp.begin(), dp.end())<<"\n"; return 0; } /* [ ]Leu o problema certo??? [ ]Ver se precisa de long long [ ]Viu o limite dos fors (é n? é m?) [ ]Tamanho do vetor, será que é 2e5 em vez de 1e5?? [ ]Testar sample [ ]Testar casos de borda [ ]1LL no 1LL << i [ ]Testar mod (é 1e9+7, mesmo?, será que o mod não ficou negativo?) */
#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...