답안 #207487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207487 2020-03-07T16:07:52 Z mohamedsobhi777 학교 설립 (IZhO13_school) C++14
0 / 100
143 ms 262148 KB
#include<bits/stdc++.h> 
 
using namespace std ;

const int N = 3e5 + 7 ; 

int n , m , k ; 
int a[N] , b[N] ; 

long long dp[500][500][500];

long long solve(int i , int M , int K)
{
    if(i==n)
    {
        return (!M && !K?0 : -1e14);
    }
    if(dp[i][M][K]!=-1)
        return dp[i][M][K];
    long long ret = solve(i+1 , M , K) ; 
    ret = max(ret , a[i] + solve(i+1 , M-1 , K) ) ; 
    ret = max(ret , solve(i+1 , M , K-1) + b[i] ) ; 
    return dp[i][M][K] = ret ; 
}


int main() 
{
    memset(dp , -1 , sizeof dp) ; 
    freopen("school.in" , "r" , stdin) ; 
    freopen("school.out" , "w" , stdout) ; 
    cin>>n>>m>>k ;
    for(int i= 0 ; i < n ; i++)
        cin>>a[i]>>b[i];
    cout<<solve(0, m , k) ; 
    return 0 ;  
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("school.in" , "r" , stdin) ; 
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("school.out" , "w" , stdout) ; 
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 132 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 136 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 133 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 136 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 134 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 135 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 135 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 132 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 133 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 135 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 137 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 133 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 134 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 137 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 136 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 143 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 137 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 137 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 135 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 138 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)