提出 #60959528


ソースコード 拡げる

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#include <queue>
#include <sstream>
#include <ctime>
#include <iterator>
#include <string.h>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <fstream>
#include <assert.h>
#include <numeric>
#include <complex>
#include <random>
#include <utility>



#define IOS ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define PB push_back
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define VI vector<int>
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VL vector<long long >
#define FILL(a, value) memset(a, value, sizeof(a))
#define double long double
const int nax = 2 * (int)1e5 + 147;
 
using namespace std;
 
const int MOD = 998244353;
const int INF = 1e9 +47 ;
const long long LINF = (long long)1e18 + 4747;
 
typedef long long LL;
const double EPS = 1e-7;

int dp[3010][3010];
int main() {
    int n;
    cin >> n;
    VI h(n);
    FOR (i, 0, n) {
        cin >> h[i];
    }
    FOR (i, 0, n) {
        dp[0][i] = 1;
    }
    FOR (i, 1, n) {
        FOR (j, 0, n) {
            if(i >= j && h[i] == h[i -j]) {
                dp[i][j] = max(dp[i][j], dp[i - j][j] + 1);
            }
            dp[i][j] = max(1 ,dp[i][j]);
        }
    }
   // cout << dp[1][2] << '\n';
    int ans = 0;
    FOR (i, 0, n) {
        FOR (j, 0, n) {
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << '\n';
}
 

提出情報

提出日時
問題 C - Illuminate Buildings
ユーザ ebiarat
言語 C++ 20 (gcc 12.2)
得点 350
コード長 1764 Byte
結果 AC
実行時間 51 ms
メモリ 38884 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 350 / 350
結果
AC × 3
AC × 28
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 38 ms 38756 KiB
random_02.txt AC 16 ms 20424 KiB
random_03.txt AC 33 ms 38812 KiB
random_04.txt AC 4 ms 7480 KiB
random_05.txt AC 38 ms 38756 KiB
random_06.txt AC 16 ms 20840 KiB
random_07.txt AC 32 ms 38884 KiB
random_08.txt AC 1 ms 4088 KiB
random_09.txt AC 38 ms 38724 KiB
random_10.txt AC 29 ms 33016 KiB
random_11.txt AC 32 ms 38884 KiB
random_12.txt AC 3 ms 5952 KiB
random_13.txt AC 38 ms 38808 KiB
random_14.txt AC 30 ms 32544 KiB
random_15.txt AC 32 ms 38820 KiB
random_16.txt AC 15 ms 20660 KiB
random_17.txt AC 37 ms 38764 KiB
random_18.txt AC 31 ms 34124 KiB
random_19.txt AC 33 ms 38820 KiB
random_20.txt AC 26 ms 32344 KiB
random_21.txt AC 51 ms 38808 KiB
random_22.txt AC 50 ms 38116 KiB
random_23.txt AC 50 ms 38756 KiB
random_24.txt AC 33 ms 38724 KiB
random_25.txt AC 1 ms 3596 KiB
sample_01.txt AC 1 ms 3512 KiB
sample_02.txt AC 1 ms 3708 KiB
sample_03.txt AC 1 ms 3536 KiB