結果
問題 | No.324 落ちてた閉路グラフ |
ユーザー | 👑 kmjp |
提出日時 | 2015-12-17 00:12:33 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,259 bytes |
コンパイル時間 | 1,226 ms |
コンパイル使用メモリ | 146,392 KB |
実行使用メモリ | 326,444 KB |
最終ジャッジ日時 | 2023-10-14 11:40:19 |
合計ジャッジ時間 | 9,824 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 170 ms
326,036 KB |
testcase_01 | AC | 171 ms
326,220 KB |
testcase_02 | AC | 171 ms
326,104 KB |
testcase_03 | AC | 174 ms
326,072 KB |
testcase_04 | AC | 196 ms
326,044 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 161 ms
326,112 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 163 ms
326,088 KB |
testcase_17 | AC | 163 ms
326,020 KB |
testcase_18 | AC | 163 ms
326,220 KB |
testcase_19 | WA | - |
testcase_20 | AC | 162 ms
326,268 KB |
testcase_21 | AC | 163 ms
326,204 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 163 ms
326,020 KB |
testcase_25 | AC | 162 ms
326,300 KB |
testcase_26 | AC | 162 ms
326,268 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 162 ms
326,148 KB |
testcase_30 | AC | 162 ms
326,100 KB |
testcase_31 | AC | 162 ms
326,016 KB |
testcase_32 | WA | - |
testcase_33 | AC | 212 ms
326,160 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,M; int W[5000]; int dp[3][3][3030][3030]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M; FOR(i,N) cin>>W[i]; memset(dp,0xce,sizeof(dp)); dp[0][0][0][0]=dp[1][1][0][1]=0; int ma=-100000000; FOR(r,2) { FOR(i,N-1) { FOR(j,M+1) { dp[r][0][i+1][j]=max(dp[r][0][i][j],dp[r][1][i][j]); dp[r][1][i+1][j]=dp[r][0][i][j]; if(j) dp[r][1][i+1][j]=max(dp[r][1][i+1][j],dp[r][1][i][j-1]+W[i]); if(j) dp[r][1][i+1][j]=max(dp[r][1][i+1][j],dp[r][0][i][j-1]); } } ma=max(ma,dp[r][0][N-1][M]); if(r==1) ma=max(ma,dp[r][1][N-1][M-1]+W[N-1]); } cout<<ma<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }