Submission #625935


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


class Room
{
public:
  int id;
  int score;
  Room(){id = 0; score = 0;};
};

bool operator<(const Room& r1, const Room& r2) {
  return r1.score != r2.score
         ? r1.score < r2.score
         : r1.id < r2.id;
}


int main()
{
  int n;
  cin >> n;
  vector<Room> rs(n);
  for(int i = 0; i < n; ++i)
  {
    int score;
    cin >> score;
    rs[i].id = i;
    rs[i].score = score;
  }

  sort(rs.begin(), rs.end());

  int prev_id = -1,
      cur_score = rs[0].score,
      loop = 0;
  for(int i = 0; i < n;)
  {
    if(rs[i].score == cur_score)
    {
      if(rs[i].id > prev_id)
      {
        if(i == 0 || rs[i-1].score < cur_score)
        {
          while(i < n && rs[i].score == cur_score) ++i;
          if(i == n) ++loop;
          else
          { 
            prev_id = rs[i-1].id;
            cur_score = rs[i].score;
          }
        }
        else
        {
          prev_id = rs[i].id;
          while(i < n && rs[i].score == cur_score) ++i;
          if(i != n) cur_score = rs[i].score;
          ++loop;
        }
      }
      else
      {
        if(i == n-1) loop += rs[i].id == 0 ? 1 : 2;
        ++i;
      }
    }
    else
    {
      prev_id = rs[i-1].id;
      cur_score = rs[i].score;
      ++loop;
    }
  }

  cout << loop << endl;

  return 0;
}

Submission Info

Submission Time
Task B - ディスコ社内ツアー
User k_opt
Language C++ (GCC 4.9.2)
Score 10
Code Size 1447 Byte
Status WA
Exec Time 92 ms
Memory 1696 KiB

Judge Result

Set Name Sample Small Permutation All
Score / Max Score 0 / 0 0 / 20 10 / 10 0 / 70
Status
AC × 4
AC × 19
WA × 7
AC × 23
AC × 31
WA × 17
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt
Small 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt
Permutation 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt, 50_rand_01.txt, 50_rand_02.txt, 50_rand_03.txt, 50_rand_04.txt, 50_rand_05.txt, 50_rand_06.txt, 50_rand_07.txt, 50_rand_08.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt, 70_hand_03.txt, 70_hand_04.txt, 70_hand_05.txt, 70_hand_06.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 26 ms 796 KiB
00_example_02.txt AC 28 ms 924 KiB
00_example_03.txt AC 27 ms 740 KiB
00_example_04.txt AC 27 ms 800 KiB
10_rand_01.txt WA 26 ms 836 KiB
10_rand_02.txt WA 27 ms 804 KiB
10_rand_03.txt WA 27 ms 800 KiB
10_rand_04.txt AC 27 ms 796 KiB
10_rand_05.txt AC 27 ms 916 KiB
10_rand_06.txt WA 27 ms 920 KiB
10_rand_07.txt WA 27 ms 916 KiB
10_rand_08.txt WA 27 ms 920 KiB
20_perm_01.txt AC 27 ms 920 KiB
20_perm_02.txt AC 27 ms 800 KiB
20_perm_03.txt AC 26 ms 920 KiB
20_perm_04.txt AC 27 ms 924 KiB
20_perm_05.txt AC 27 ms 808 KiB
20_perm_06.txt AC 27 ms 924 KiB
20_perm_07.txt AC 25 ms 800 KiB
20_perm_08.txt AC 26 ms 920 KiB
30_hand_01.txt AC 27 ms 920 KiB
30_hand_02.txt AC 28 ms 920 KiB
30_hand_03.txt AC 26 ms 920 KiB
30_hand_04.txt AC 26 ms 920 KiB
30_hand_05.txt AC 26 ms 928 KiB
30_hand_06.txt WA 26 ms 916 KiB
50_rand_01.txt WA 45 ms 1184 KiB
50_rand_02.txt WA 64 ms 1436 KiB
50_rand_03.txt WA 66 ms 1436 KiB
50_rand_04.txt WA 58 ms 1180 KiB
50_rand_05.txt WA 38 ms 1048 KiB
50_rand_06.txt WA 27 ms 796 KiB
50_rand_07.txt WA 33 ms 920 KiB
50_rand_08.txt WA 58 ms 1304 KiB
60_perm_01.txt AC 47 ms 1180 KiB
60_perm_02.txt AC 71 ms 1432 KiB
60_perm_03.txt AC 70 ms 1312 KiB
60_perm_04.txt AC 61 ms 1304 KiB
60_perm_05.txt AC 41 ms 928 KiB
60_perm_06.txt AC 25 ms 920 KiB
60_perm_07.txt AC 31 ms 924 KiB
60_perm_08.txt AC 62 ms 1304 KiB
70_hand_01.txt AC 83 ms 1692 KiB
70_hand_02.txt AC 80 ms 1568 KiB
70_hand_03.txt AC 69 ms 1696 KiB
70_hand_04.txt AC 68 ms 1568 KiB
70_hand_05.txt WA 92 ms 1496 KiB
70_hand_06.txt WA 82 ms 1568 KiB