Submission #295766


Source Code Expand

#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
double prob[128][256][128];
// already,last, n-th
int main(void)
{
  int n,k;
  cin >> n >> k;
  REP(already,n+1) REP(last,k+1) REP(i,n+1) prob[already][last][i]=0.0;
  double p;
  cin >> p;
  prob[1][1][1]=1.0;
  FOR(i,1,n){
    cin >> p;
    p/=100;
    REP(already,n+1) REP(last,k+1){
      if(already<last)
	prob[already+1][last][i+1]+=prob[already][last][i]*p;
      else if(already<k)
	prob[already+1][last+1][i+1]+=prob[already][last][i]*p;
      else
	prob[already][last][i+1]+=prob[already][last][i]*p;
      if(last+1<k)
	prob[already+1][last+2][i+1]+=prob[already][last][i]*(1-p);
      else
	prob[already][last][i+1]+=prob[already][last][i]*(1-p);
    }
  }
  double exp=0.0;
  REP(already,n+1) REP(last,k+1) exp+=prob[already][last][n]*already;
  cout << fixed << setprecision(10) << k-exp << endl;    
  return 0;
}

Submission Info

Submission Time
Task G - 通勤電車と気分
User siotouto
Language C++ (G++ 4.6.4)
Score 100
Code Size 1056 Byte
Status AC
Exec Time 156 ms
Memory 21684 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 30 / 30 70 / 70
Status
AC × 3
AC × 22
AC × 41
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask sample_01.txt, sample_02.txt, sample_03.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt, small_05.txt, small_06.txt, subtask_01.txt, subtask_02.txt, subtask_03.txt, subtask_04.txt, subtask_05.txt, subtask_06.txt, subtask_07.txt, subtask_08.txt, subtask_09.txt, subtask_10.txt, subtask_11.txt, subtask_12.txt, subtask_13.txt
All large_01.txt, large_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt, small_05.txt, small_06.txt, subtask_01.txt, subtask_02.txt, subtask_03.txt, subtask_04.txt, subtask_05.txt, subtask_06.txt, subtask_07.txt, subtask_08.txt, subtask_09.txt, subtask_10.txt, subtask_11.txt, subtask_12.txt, subtask_13.txt
Case Name Status Exec Time Memory
large_01.txt AC 115 ms 11436 KB
large_02.txt AC 87 ms 11448 KB
random_01.txt AC 94 ms 11560 KB
random_02.txt AC 75 ms 10288 KB
random_03.txt AC 46 ms 5416 KB
random_04.txt AC 31 ms 2580 KB
random_05.txt AC 29 ms 1328 KB
random_06.txt AC 87 ms 12724 KB
random_07.txt AC 97 ms 14824 KB
random_08.txt AC 111 ms 17588 KB
random_09.txt AC 131 ms 20844 KB
random_10.txt AC 80 ms 11568 KB
random_11.txt AC 86 ms 11572 KB
random_12.txt AC 82 ms 11568 KB
random_13.txt AC 30 ms 2216 KB
random_14.txt AC 29 ms 2104 KB
random_15.txt AC 30 ms 2140 KB
random_16.txt AC 90 ms 13416 KB
random_17.txt AC 97 ms 14312 KB
random_18.txt AC 133 ms 21684 KB
random_19.txt AC 156 ms 21336 KB
random_20.txt AC 84 ms 11576 KB
sample_01.txt AC 24 ms 1044 KB
sample_02.txt AC 24 ms 952 KB
sample_03.txt AC 30 ms 1056 KB
small_01.txt AC 27 ms 876 KB
small_02.txt AC 27 ms 936 KB
small_03.txt AC 26 ms 1432 KB
small_04.txt AC 26 ms 860 KB
small_05.txt AC 26 ms 1048 KB
small_06.txt AC 26 ms 1048 KB
subtask_01.txt AC 27 ms 1176 KB
subtask_02.txt AC 26 ms 1052 KB
subtask_03.txt AC 27 ms 1208 KB
subtask_04.txt AC 25 ms 1076 KB
subtask_05.txt AC 24 ms 1076 KB
subtask_06.txt AC 26 ms 1004 KB
subtask_07.txt AC 29 ms 2588 KB
subtask_08.txt AC 26 ms 944 KB
subtask_09.txt AC 27 ms 932 KB
subtask_10.txt AC 26 ms 992 KB
subtask_11.txt AC 24 ms 1128 KB
subtask_12.txt AC 25 ms 1176 KB
subtask_13.txt AC 26 ms 1068 KB