Submission #1771623


Source Code Expand

#include <cstdio>
using namespace std;
void quick_sort(long numbers[], long length){
  if (length == 1 || length == 0){
    return;
  }
  long border = numbers[0];
  long left[length];
  long right[length];
  long i = 0;
  long j = 0;
  for (long k = 1; k < length; k++){
    if (numbers[k] < border){
      left[i] = numbers[k];
      i++;
    }
    else {
      right[j] = numbers[k];
      j++;
    }
  }
  quick_sort(left, i);
  quick_sort(right, j);
  for (long l = 0; l < i; l++){
    numbers[l] = left[l];
  }
  numbers[i] = border;
  for(long l = i + 1; l < length; l++){
    numbers[l] = right[l - i - 1];
  }
}
int main(){
  long index;
  scanf("%ld", &index);
  long *difficulties = new long[index];
  for(long i = 0; i < index; i++){
    scanf("%ld", difficulties + i);
  }
  quick_sort(difficulties, index);
  long *multi_indexes = new long[index];
  long current_polonger = 0;
  for(long i = 0; i < index; i++){
    while(true){
      if (current_polonger == index){
        break;
      }
      if (difficulties[current_polonger] >= difficulties[i] * 2){
        multi_indexes[i] = current_polonger;
        break;
      }
      else{
        current_polonger++;
      }
    }
    if (current_polonger == index){
      for (long j = i; j < index; j++){
        multi_indexes[j] = -1;
      }
      break;
    }
  }
  delete[] difficulties;
  long *two_choice = new long[index];
  for(long i = 0; i < index; i++){
    if(multi_indexes[i] >= 0){
      two_choice[i] = index - multi_indexes[i];
    }
    else{
      two_choice[i] = 0;
    }
  }
  current_polonger = index - 1;
  long *three_choice = new long[index];
  long sum = 0;
  for(long i = index - 1; i >= 0; i--){
    if(multi_indexes[i] < 0){
      three_choice[i] = 0;
    }
    else{
      while(current_polonger >= multi_indexes[i]){
        sum += two_choice[current_polonger] % 1000000007;
        current_polonger--;
        sum = sum % 1000000007;
      }
      three_choice[i] = sum;
    }
  }
  delete[] two_choice;
  current_polonger = index - 1;
  long *four_choice = new long[index];
  sum = 0;
  for(long i = index - 1; i >= 0; i--){
    if(multi_indexes[i] < 0){
      four_choice[i] = 0;
    }
    else{
      while(current_polonger >= multi_indexes[i]){
        sum += three_choice[current_polonger] % 1000000007;
        current_polonger--;
        sum = sum % 1000000007;
      }
      four_choice[i] = sum;
    }
  }
  delete[] multi_indexes;
  delete[] three_choice;
  long result = 0;
  for(long i = 0; i < index; i++){
    result += four_choice[i];
    result = result % 1000000007;
  }
    printf("%ld\n", result % 1000000007);
}

Submission Info

Submission Time
Task A - 点数変換
User liwii
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2737 Byte
Status RE
Exec Time 173 ms
Memory 132608 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%ld", &index);
                       ^
./Main.cpp:37:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%ld", difficulties + i);
                                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
WA × 3
WA × 40
RE × 5
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask1_26.txt, subtask1_27.txt, subtask1_28.txt, subtask1_29.txt, subtask1_30.txt, subtask1_31.txt, subtask1_32.txt, subtask1_33.txt, subtask1_34.txt, subtask1_35.txt, subtask1_36.txt, subtask1_37.txt, subtask1_38.txt, subtask1_39.txt
Case Name Status Exec Time Memory
sample_01.txt WA 1 ms 256 KB
sample_02.txt WA 1 ms 256 KB
sample_03.txt WA 1 ms 256 KB
subtask1_01.txt WA 10 ms 3036 KB
subtask1_02.txt RE 169 ms 132608 KB
subtask1_03.txt WA 16 ms 4640 KB
subtask1_04.txt WA 5 ms 1408 KB
subtask1_05.txt WA 25 ms 6544 KB
subtask1_06.txt WA 19 ms 6504 KB
subtask1_07.txt WA 25 ms 6148 KB
subtask1_08.txt WA 17 ms 5652 KB
subtask1_09.txt WA 7 ms 1988 KB
subtask1_10.txt WA 8 ms 2468 KB
subtask1_11.txt WA 13 ms 3740 KB
subtask1_12.txt RE 169 ms 132224 KB
subtask1_13.txt WA 9 ms 2824 KB
subtask1_14.txt WA 2 ms 512 KB
subtask1_15.txt WA 16 ms 4008 KB
subtask1_16.txt WA 16 ms 4380 KB
subtask1_17.txt WA 7 ms 1600 KB
subtask1_18.txt WA 16 ms 4248 KB
subtask1_19.txt WA 27 ms 10372 KB
subtask1_20.txt WA 26 ms 7408 KB
subtask1_21.txt WA 27 ms 7536 KB
subtask1_22.txt RE 170 ms 132096 KB
subtask1_23.txt WA 26 ms 6384 KB
subtask1_24.txt WA 26 ms 7920 KB
subtask1_25.txt WA 27 ms 7792 KB
subtask1_26.txt WA 26 ms 6384 KB
subtask1_27.txt WA 27 ms 7792 KB
subtask1_28.txt WA 28 ms 9968 KB
subtask1_29.txt WA 26 ms 6512 KB
subtask1_30.txt WA 26 ms 7408 KB
subtask1_31.txt WA 26 ms 6896 KB
subtask1_32.txt RE 169 ms 132096 KB
subtask1_33.txt WA 27 ms 8176 KB
subtask1_34.txt WA 26 ms 6896 KB
subtask1_35.txt WA 26 ms 6256 KB
subtask1_36.txt WA 26 ms 7408 KB
subtask1_37.txt WA 26 ms 7408 KB
subtask1_38.txt WA 27 ms 7792 KB
subtask1_39.txt RE 173 ms 132096 KB