Submission #1368817


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  vector<vector<int>> vec(n,vector<int>(n,0));
  rep(i,n)rep(j,i+1) cin>>vec[i][j];
  vector<vector<int>> dp(n+1,vector<int>(n+1,0));

  rep(i,n)rep(j,i+1){
    dp[i+1][j] = max(dp[i+1][j], dp[i][j]+vec[i][j]);
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+vec[i][j]);
  }

  cout << *max_element(all(dp[n])) << endl;

  return 0;
}

Submission Info

Submission Time
Task D - 三角パズル
User tossy
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1210 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name sub1 sub2
Score / Max Score 50 / 50 50 / 50
Status
AC × 13
AC × 24
Set Name Test Cases
sub1 sub1/input_0.txt, sub1/input_1.txt, sub1/input_14.txt, sub1/input_15.txt, sub1/input_18.txt, sub1/input_19.txt, sub1/input_2.txt, sub1/input_20.txt, sub1/input_3.txt, sub1/input_4.txt, sub1/input_5.txt, sub1/input_6.txt, sub1/input_9.txt
sub2 sub2/input_0.txt, sub2/input_1.txt, sub2/input_10.txt, sub2/input_11.txt, sub2/input_12.txt, sub2/input_13.txt, sub2/input_14.txt, sub2/input_15.txt, sub2/input_16.txt, sub2/input_17.txt, sub2/input_18.txt, sub2/input_19.txt, sub2/input_2.txt, sub2/input_20.txt, sub2/input_21.txt, sub2/input_22.txt, sub2/input_23.txt, sub2/input_3.txt, sub2/input_4.txt, sub2/input_5.txt, sub2/input_6.txt, sub2/input_7.txt, sub2/input_8.txt, sub2/input_9.txt
Case Name Status Exec Time Memory
sub1/input_0.txt AC 1 ms 256 KB
sub1/input_1.txt AC 1 ms 256 KB
sub1/input_14.txt AC 1 ms 256 KB
sub1/input_15.txt AC 1 ms 256 KB
sub1/input_18.txt AC 1 ms 256 KB
sub1/input_19.txt AC 1 ms 256 KB
sub1/input_2.txt AC 1 ms 256 KB
sub1/input_20.txt AC 1 ms 256 KB
sub1/input_3.txt AC 1 ms 256 KB
sub1/input_4.txt AC 1 ms 256 KB
sub1/input_5.txt AC 1 ms 256 KB
sub1/input_6.txt AC 1 ms 256 KB
sub1/input_9.txt AC 1 ms 256 KB
sub2/input_0.txt AC 1 ms 256 KB
sub2/input_1.txt AC 1 ms 256 KB
sub2/input_10.txt AC 1 ms 256 KB
sub2/input_11.txt AC 1 ms 256 KB
sub2/input_12.txt AC 1 ms 256 KB
sub2/input_13.txt AC 1 ms 256 KB
sub2/input_14.txt AC 1 ms 256 KB
sub2/input_15.txt AC 1 ms 256 KB
sub2/input_16.txt AC 1 ms 256 KB
sub2/input_17.txt AC 1 ms 256 KB
sub2/input_18.txt AC 1 ms 256 KB
sub2/input_19.txt AC 1 ms 256 KB
sub2/input_2.txt AC 1 ms 256 KB
sub2/input_20.txt AC 1 ms 256 KB
sub2/input_21.txt AC 1 ms 256 KB
sub2/input_22.txt AC 1 ms 256 KB
sub2/input_23.txt AC 1 ms 256 KB
sub2/input_3.txt AC 1 ms 256 KB
sub2/input_4.txt AC 1 ms 256 KB
sub2/input_5.txt AC 1 ms 256 KB
sub2/input_6.txt AC 1 ms 256 KB
sub2/input_7.txt AC 1 ms 256 KB
sub2/input_8.txt AC 1 ms 256 KB
sub2/input_9.txt AC 1 ms 256 KB