제출 #47837

#제출 시각아이디문제언어결과실행 시간메모리
47837TheDarkningCandies (JOI18_candies)C++17
8 / 100
956 ms395448 KiB
/**
                  ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀
                  <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋>

            ♔♕♖♗♘♙ ☜❷☞✪ ィℋ६ ≈ ᗫẵℜℵĬŊĞ ✪☜❷☞ ♚♛♜♝♞♟
            ♔♕♖♗♘♙                             ♚♛♜♝♞♟
                      ˙·٠•●♥ Ƹ̵̡Ӝ̵̨̄Ʒ ♥●•٠·˙
                      916 921 919 673
**/

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <time.h>
#include <map>
#include <deque>
#include <assert.h>
#include <queue>
#include <string>
#include <memory.h>
#include <set>
#include <math.h>

#define sz(s) s.size()
#define pb emplace_back
#define fr first
#define sc second
#define mk make_pair
#define int long long
#define all(s) s.begin(), s.end()
#define ok puts("ok");

using namespace std;

const int N = 2e5 + 5;
const int inf = 1e18 + 7;

int n, ar[N], dp[5000][5000];

main(){
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        scanf("%d", &ar[i]);
    }
    for( int i = 0; i <= n; i++ ){
        for( int j = 0; j <= n; j++ ){
            dp[ i ][ j ] = -inf;
        }
    }

    dp[ 0 ][ 0 ] = 0;

    dp[ 0 ][ 1 ] = 0;
    dp[ 1 ][ 1 ] = ar[ 1 ];

    for( int i = 2; i <= n; i++ ){
        int cur = 0;
        for( int j = 0; j <= i; j++ ){
            cur = dp[j][ i - 1 ];
            if( j )
                cur = max( cur, dp[ j - 1 ][ i - 2 ] + ar[ i ] );
            dp[ j ][ i ] = cur;
        }
    }
    for( int i = 1; i <= ( n + 1 ) / 2; i++ ){
        cout << dp[ i ][ n ] << endl;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

candies.cpp:42:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
candies.cpp: In function 'int main()':
candies.cpp:45:27: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%d", &ar[i]);
                     ~~~~~~^
candies.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &ar[i]);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...