DPのD〜が出てこない〜♪
DPという文字が出てきてたらもう少しマシだったのではないか???
といわざるおえない結果。。。
たぶん3完と4の部分点。本戦いくのがワンチャン(^_^;)
1
void solve() { int pasta=INT_MAX, juice=INT_MAX; for (int i=0; i<3; i++) { int t; scanf("%d",&t); pasta = min(pasta, t); } for (int i=0; i<2; i++) { int t; scanf("%d", &t); juice = min(juice, t); } printf("%d\n", pasta+juice-50); } int main() { solve(); return 0; }
2
void solve() { int n; scanf("%d", &n); vector<P> team(n), res(n); for (int i=0; i<n; i++) { team[i].first = 0; team[i].second = i+1; } for (int i=0; i<n*(n-1)/2; i++) { int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d); if (c > d) { team[a-1].first += 3; } else if (c < d) { team[b-1].first += 3; } else { team[a-1].first++; team[b-1].first++; } } sort(team.begin(), team.end()); int place = 0, bef = INT_MAX, temp=0; for (int i=n-1; i>=0; i--) { if (bef != team[i].first) { place+=temp+1; temp=0; res[i].second = place; } else { temp++; res[i].second = place; } bef = team[i].first; res[i].first = team[i].second; } sort(res.begin(), res.end()); for (int i=0; i<n; i++) printf("%d\n",res[i].second); } int main() { solve(); return 0; }
3
void solve() { int n, a, b, c; scanf("%d%d%d%d",&n,&a,&b,&c); int top[n]; for (int i=0; i<n; i++) scanf("%d",&top[i]); sort(top, top+n, greater<int>()); int res = 0; int cal = 0; for (int i=0; i<n; i++) { cal += top[i]; res = max(res, (cal+c)/(a+b*(i+1))); } printf("%d\n", res); } int main() { solve(); return 0; }
ここまでは良かった。
4
ll dfs(int s, int bef, int cnt, int n, int day[]) { ll res = 0; if (s == n) return 1; if (day[s]==0) { for (int i=1; i<=3; i++) { if (bef==i&&cnt==2) continue; else if (bef!=i) res += dfs(s+1, i, 1, n, day); else res += dfs(s+1, i, cnt+1, n, day); } } else { if (bef==day[s]&&cnt==2) return 0; else if (bef!=day[s]) res += dfs(s+1, day[s], 1, n, day); else res += dfs(s+1, day[s], cnt+1, n, day); } return res; } void solve() { int n, k, a, b; scanf("%d%d",&n,&k); int day[n]; fill(day, day+n, 0); for (int i=0; i<k; i++) { scanf("%d%d",&a,&b); day[a-1]=b; } ll res = 0; if (day[0]==0) { for (int i=1; i<=3; i++) { res += dfs(1, i, 1, n, day); } } else { res += dfs(1, day[0], 1, n, day); } printf("%lld\n",res%10000); } int main() { solve(); return 0; }
当然3~5がほぼTLE状態。
とりあえず部分点を狙いに行く
5
試行錯誤してたら大変なことに。
サンプルは通ったけど、引き方が悪かったようで採点用は全部落ちた・・・
int w, h; int field[100][100]; int d1[6][2] = {{-1,-1},{-1,0},{0,1},{1,0},{1,-1},{0,-1}}; int d2[6][2] = {{-1,0},{-1,1},{0,1},{1,1},{1,0},{0,-1}}; int dfs(int x, int y) { field[x][y]++; int res = 0; if (x%2==0) { for (int i=0; i<6; i++) { int nx=x+d2[i][0],ny=y+d2[i][1]; if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==1) { res += dfs(nx, ny); } else if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==2) { res += 0; } else { res++; } } } else { for (int i=0; i<6; i++) { int nx=x+d1[i][0],ny=y+d1[i][1]; if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==1) { res += dfs(nx, ny); } else if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==2) { res += 0; } else { res++; } } } return res; } bool judge(int x, int y) { field[x][y]--; if (x%2==0) { for (int i=0; i<6; i++) { int nx=x+d2[i][0],ny=y+d2[i][1]; if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==0) { return judge(nx,ny); } else if (nx<0||nx>=h||ny<0||ny>=w) { return false; } } } else { for (int i=0; i<6; i++) { int nx=x+d1[i][0],ny=y+d1[i][1]; if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==0) { return judge(nx,ny); } else if (nx<0||nx>=h||ny<0||ny>=w) { return false; } } } return true; } int count(int x, int y) { field[x][y]--; int res=0; if (x%2==0) { for (int i=0; i<6; i++) { int nx=x+d2[i][0],ny=y+d2[i][1]; if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==-1) { res += count(nx, ny); } else if (nx>=0&&nx<h&&ny>=0&&ny<w&&(field[nx][ny]==1||field[nx][ny]==2)){ res++; } } } else { for (int i=0; i<6; i++) { int nx=x+d1[i][0],ny=y+d1[i][1]; if (nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==-1) { res += count(nx, ny); } else if (nx>=0&&nx<h&&ny>=0&&ny<w&&(field[nx][ny]==1||field[nx][ny]==2)){ res++; } } } return res; } void solve() { scanf("%d%d",&w,&h); int res=0; for (int i=0; i<h; i++) for (int j=0; j<w; j++) scanf("%d",&field[i][j]); for (int i=0; i<h; i++) { for (int j=0; j<w; j++) { if (field[i][j]==1) res += dfs(i,j); else if (field[i][j]==0&&judge(i,j)) { res -= count(i,j); } } } printf("%d\n", res); } int main() { solve(); return 0; }
6
DPのDの字が出て来なかったんだから解けるわけ無いでしょ(笑)
異常
以上