Submission #60755605


Source Code Expand

Copy
#include <iostream>
using namespace std;
typedef long long sll;
sll A[400000];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
sll N, S;
cin >> N >> S;
sll period = 0;
for (int i = 0; i < N; i++) {
cin >> A[i];
A[N + i] = A[i];
period += A[i];
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <iostream>
using namespace std;

typedef long long sll;

sll A[400000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  sll N, S;
  cin >> N >> S;

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

  S %= period;

  int l = 0, r = 0;

  sll sum = 0;
  bool ans = false;
  while (l < 2 * N) {
    if (sum == S) {
      ans = true;
      break;
    }

    if (r < 2 * N && sum < S) {
      sum += A[r++];
    } else {
      sum -= A[l++];
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';

  return 0;
}

Submission Info

Submission Time
Task D - Repeated Sequence
User riverlike14
Language C++ 20 (gcc 12.2)
Score 400
Code Size 641 Byte
Status AC
Exec Time 15 ms
Memory 6736 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 54
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 02_handmade_46.txt, 02_handmade_47.txt, 02_handmade_48.txt, 02_handmade_49.txt, 02_handmade_50.txt, 02_handmade_51.txt, 02_handmade_52.txt, 02_handmade_53.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3528 KB
00_sample_01.txt AC 1 ms 3332 KB
00_sample_02.txt AC 1 ms 3536 KB
00_sample_03.txt AC 1 ms 3468 KB
01_random_04.txt AC 13 ms 6536 KB
01_random_05.txt AC 15 ms 6668 KB
01_random_06.txt AC 13 ms 6660 KB
01_random_07.txt AC 15 ms 6536 KB
01_random_08.txt AC 13 ms 6732 KB
01_random_09.txt AC 15 ms 6520 KB
01_random_10.txt AC 15 ms 6592 KB
01_random_11.txt AC 15 ms 6600 KB
01_random_12.txt AC 13 ms 6548 KB
01_random_13.txt AC 13 ms 6600 KB
01_random_14.txt AC 14 ms 6544 KB
01_random_15.txt AC 15 ms 6608 KB
01_random_16.txt AC 12 ms 6524 KB
01_random_17.txt AC 14 ms 6524 KB
01_random_18.txt AC 12 ms 6732 KB
01_random_19.txt AC 15 ms 6736 KB
01_random_20.txt AC 14 ms 6664 KB
01_random_21.txt AC 12 ms 6556 KB
01_random_22.txt AC 13 ms 6572 KB
01_random_23.txt AC 14 ms 6580 KB
01_random_24.txt AC 13 ms 6592 KB
01_random_25.txt AC 12 ms 6520 KB
01_random_26.txt AC 12 ms 6656 KB
01_random_27.txt AC 12 ms 6592 KB
01_random_28.txt AC 8 ms 5332 KB
01_random_29.txt AC 1 ms 3544 KB
01_random_30.txt AC 2 ms 3660 KB
01_random_31.txt AC 6 ms 4688 KB
01_random_32.txt AC 11 ms 6052 KB
01_random_33.txt AC 1 ms 3556 KB
01_random_34.txt AC 5 ms 4792 KB
01_random_35.txt AC 3 ms 4104 KB
01_random_36.txt AC 3 ms 4020 KB
01_random_37.txt AC 9 ms 5552 KB
01_random_38.txt AC 5 ms 4540 KB
01_random_39.txt AC 2 ms 3760 KB
01_random_40.txt AC 14 ms 6596 KB
01_random_41.txt AC 12 ms 6728 KB
01_random_42.txt AC 13 ms 6540 KB
01_random_43.txt AC 4 ms 4008 KB
01_random_44.txt AC 7 ms 4684 KB
01_random_45.txt AC 2 ms 3580 KB
02_handmade_46.txt AC 8 ms 6600 KB
02_handmade_47.txt AC 1 ms 3448 KB
02_handmade_48.txt AC 7 ms 6540 KB
02_handmade_49.txt AC 1 ms 3604 KB
02_handmade_50.txt AC 14 ms 6728 KB
02_handmade_51.txt AC 13 ms 6536 KB
02_handmade_52.txt AC 9 ms 6596 KB
02_handmade_53.txt AC 10 ms 6600 KB


2025-03-05 (Wed)
12:27:36 +00:00