Submission #1234291

#TimeUsernameProblemLanguageResultExecution timeMemory
1234291yixuan19Global Warming (CEOI18_glo)C++20
0 / 100
2097 ms2748 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, max_change, temp; cin >> N >> max_change; vector<int> temps; for (int i = 0; i < N; ++i){ cin >> temp; temps.push_back(temp); } int dp[N+1][2]; for (int i = 0; i < N; ++i){ for (int j = 0; j < 2; ++j){ dp[i][j] = 0; } } dp[0][0] = 1; dp[0][1] = 1; for (int i = 1; i < N; ++i){ int maxi0 = 0; for (int j = 0; j < i; ++j){ if (temps[j] <= temps[i] -1){ maxi0 = max(maxi0,dp[j][0]+1); } } int maxi1= 0; for (int j = 0; j < i; ++j){ if (temps[j] <= temps[i] -1){ maxi1 = max(maxi1,dp[j][1]+1); } } for (int j = 0; j < i; ++j){ if (temps[j] <= temps[i] -1 + max_change){ maxi1 = max(maxi1,dp[j][0]+1); } } dp[i][0] = maxi0; dp[i][1] = maxi1; //cout<<"query 0 "<<i<<" "<<query(decalage,temps[i] + decalage -1)<<endl; //cout<<"query 1 "<<i<<" "<<query(decalage,temps[i] + decalage -1 + max_change)<<endl; //cout<<"query 2 "<<i<<" "<<query2(decalage,temps[i] + decalage -1)<<endl; //cout<<max(dp[i][1],query2(decalage,temps[i] + decalage -1))<<endl; } int maxi = 0; for (int i = 0; i < N; ++i ){ for (int j = 0; j < 2; ++j){ //cout<<dp[i][j]<<" "; maxi = max(maxi, dp[i][j]); } //cout<<endl; } cout<<maxi<<endl; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...