Submission #825052


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;

int main()
{
  int N, L, A[100000];

  cin >> N >> L;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int head = 0, tail = N - 1;
  long long all = accumulate(A, A + N, 0LL);

  vector< int > step;
  while(head != tail && all >= L) {
    if(A[head] < A[tail]) {
      all -= A[head];
      step.push_back(head);
      head++;
    } else {
      all -= A[tail];
      tail--;
      step.push_back(tail);
    }
  }

  if(head == tail) {
    cout << "Possible" << endl;
    for(int k : step) {
      cout << k + 1 << endl;
    }
  } else {
    cout << "Impossible" << endl;
  }
}

Submission Info

Submission Time
Task C - Knot Puzzle
User ei13333
Language C++14 (GCC 5.4.1)
Score 0
Code Size 667 Byte
Status
Exec Time 783 ms
Memory 1784 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
All 0 / 500 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt
Case Name Status Exec Time Memory
0_00.txt 4 ms 256 KB
0_01.txt 4 ms 256 KB
0_02.txt 4 ms 256 KB
1_00.txt 4 ms 256 KB
1_01.txt 4 ms 256 KB
1_02.txt 610 ms 1656 KB
1_03.txt 34 ms 1276 KB
1_04.txt 607 ms 1784 KB
1_05.txt 33 ms 1276 KB
1_06.txt 612 ms 1784 KB
1_07.txt 33 ms 1276 KB
1_08.txt 600 ms 1656 KB
1_09.txt 33 ms 1276 KB
1_10.txt 669 ms 1656 KB
1_11.txt 34 ms 1276 KB
1_12.txt 730 ms 1784 KB
1_13.txt 78 ms 1276 KB
1_14.txt 783 ms 1656 KB
1_15.txt 4 ms 256 KB
1_16.txt 4 ms 256 KB
1_17.txt 78 ms 1276 KB
1_18.txt 72 ms 1276 KB
1_19.txt 75 ms 1276 KB
1_20.txt 69 ms 1276 KB
1_21.txt 75 ms 1276 KB
1_22.txt 72 ms 1276 KB
1_23.txt 72 ms 1276 KB
1_24.txt 68 ms 1276 KB
1_25.txt 73 ms 1276 KB
1_26.txt 74 ms 1276 KB
1_27.txt 655 ms 1656 KB
1_28.txt 632 ms 1656 KB
1_29.txt 590 ms 1656 KB
1_30.txt 645 ms 1656 KB
1_31.txt 589 ms 1656 KB