답안 #838142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838142 2023-08-26T09:31:58 Z Dremix10 송신탑 (IOI22_towers) C++17
0 / 100
996 ms 2097152 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
const int N = 3e5+5;
const int MOD = 1e9+7;
const ll INF = 1e18+5;
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<"}"<<endl;
#else
    #define p(x) {}
    #define pv(x) {}
#endif

vector<int> arr;
int n,k;

void init(int N, vector<int> H) {
    n = N;
    arr = H;

    int i;
    
    


}

int max_towers(int L, int R, int D) {
    
    vector<vector<int> > dp(n,vector<int>(n,-MOD));
    int i,j;
    for(i=0;i<n;i++){
        dp[i][i] = 1;
    }

    // dp[i][j], max group size from {0,i} with the last chosen being j (j <= i) 
    
    for(i=1;i<n;i++){
        int maxi = -MOD;
        for(j=i-1;j>=0;j--){
            /// transition of not chosing i
            dp[i][j] = max(dp[i][j],dp[i-1][j]);

            /// transition of choosing i:
            /// must find k bt {j+1,i-1} that has conditions

            if(maxi - D >= max(arr[i],arr[j]))
                dp[i][i] = max(dp[i][i],dp[i-1][j] + 1); 
            
            maxi = max(maxi,arr[j]);
        }
        
    }

    int ret = 1;

    for(i=0;i<n;i++)ret = max(ret,dp[n-1][i]);
    return ret;
}

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:28:9: warning: unused variable 'i' [-Wunused-variable]
   28 |     int i;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 996 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 976 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 976 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 569 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 603 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 976 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 996 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -