Submission #60734896


Source Code Expand

// #undef LOCAL
#ifdef LOCAL
// #define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <array>
#include <random>
#include <cassert>
#include <chrono>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/priority_queue.hpp>
using namespace std;
#ifdef LOCAL
#include "D:\c++\Algo\Debug.h"
#define print(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
#define debug(...) (void)0
#define dbg(a, l, r) (void)0
#define print(fmt, ...) (void)0
#endif
bool Mbg;
namespace Anonyme {
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define QwQ01AwA return 0
#define mset(a, x) memset(begin(a), x, sizeof(a))
#define mcpy(a, b) memcpy(begin(a), begin(b), sizeof(a))
#define range(a, l, r) begin(a) + l, begin(a) + r + 1
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define file(x) freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using d32 = double;
using d64 = long double;
using pii = pair<int, int>;
template <class T> using vc = vector<T>;
template <class T> using pq = priority_queue<T>;
template <class T> using rpq = priority_queue<T, vector<T>, greater<T>>;
template <class T, int siz> using ar = array<T, siz>;
template <class T, class U> inline bool ckmax(T &x, U &&y) {return x < y ? (x = y, 1) : 0;}
template <class T, class U> inline bool ckmin(T &x, U &&y) {return x > y ? (x = y, 1) : 0;}
const int inf32 = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3f;

void main01() {
	#ifdef LOCAL
	file("");
	#endif
	cin.tie(nullptr) -> sync_with_stdio(false);
	int n;
	i64 res;
	cin >> n >> res;
	vc<int> a(n);
	for (auto &x : a) cin >> x;
	i64 s = accumulate(all(a), 0ll);
	vc<int> b;
	for (auto x : a) b.eb(x);
	for (auto x : a) b.eb(x);
	a = b;
	map<i64, i64> mp;
	mp[0] = 0;
	i64 pre = 0;
	for (int i = 0; i < 2 * n; i++) {
		pre += a[i];
		i64 it = (pre - res) % s;
		it = (it + s) % s;
		if (mp.find(it) != end(mp) && pre - mp[it] <= res) return cout << "Yes" << '\n', void();
		if (mp.find(pre % s) == end(mp)) mp[pre % s] = pre;
		else ckmin(mp[res % s], res);
	}
	cout << "No" << '\n'; 
}}
bool Med;
signed main() {
	Anonyme::main01();
	#ifdef LOCAL
	cerr << endl;
	cerr << "\033[0m\033[0;32m" "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n" "\033[0m";
	cerr << "\033[0m\033[0;33m" "Memory: " << abs(&Mbg - &Med) / 1048576.0 << "mb\n" "\033[0m";
	#endif
	QwQ01AwA;
}

Submission Info

Submission Time
Task D - Repeated Sequence
User Anonyme
Language C++ 20 (gcc 12.2)
Score 400
Code Size 2994 Byte
Status AC
Exec Time 148 ms
Memory 18716 KiB

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 3564 KiB
00_sample_01.txt AC 1 ms 3612 KiB
00_sample_02.txt AC 1 ms 3460 KiB
00_sample_03.txt AC 1 ms 3472 KiB
01_random_04.txt AC 44 ms 11904 KiB
01_random_05.txt AC 137 ms 18712 KiB
01_random_06.txt AC 70 ms 15692 KiB
01_random_07.txt AC 142 ms 18680 KiB
01_random_08.txt AC 93 ms 18620 KiB
01_random_09.txt AC 136 ms 18632 KiB
01_random_10.txt AC 138 ms 18692 KiB
01_random_11.txt AC 137 ms 18600 KiB
01_random_12.txt AC 56 ms 13788 KiB
01_random_13.txt AC 45 ms 12264 KiB
01_random_14.txt AC 52 ms 13420 KiB
01_random_15.txt AC 140 ms 18560 KiB
01_random_16.txt AC 87 ms 18620 KiB
01_random_17.txt AC 136 ms 18688 KiB
01_random_18.txt AC 89 ms 18356 KiB
01_random_19.txt AC 138 ms 18596 KiB
01_random_20.txt AC 139 ms 18576 KiB
01_random_21.txt AC 102 ms 18600 KiB
01_random_22.txt AC 143 ms 18608 KiB
01_random_23.txt AC 137 ms 18560 KiB
01_random_24.txt AC 148 ms 18624 KiB
01_random_25.txt AC 68 ms 15980 KiB
01_random_26.txt AC 100 ms 18716 KiB
01_random_27.txt AC 75 ms 16496 KiB
01_random_28.txt AC 32 ms 9740 KiB
01_random_29.txt AC 3 ms 3880 KiB
01_random_30.txt AC 8 ms 4644 KiB
01_random_31.txt AC 31 ms 9328 KiB
01_random_32.txt AC 108 ms 15272 KiB
01_random_33.txt AC 1 ms 3600 KiB
01_random_34.txt AC 25 ms 8388 KiB
01_random_35.txt AC 22 ms 6444 KiB
01_random_36.txt AC 5 ms 4460 KiB
01_random_37.txt AC 67 ms 13596 KiB
01_random_38.txt AC 46 ms 8728 KiB
01_random_39.txt AC 9 ms 4708 KiB
01_random_40.txt AC 137 ms 18628 KiB
01_random_41.txt AC 88 ms 18152 KiB
01_random_42.txt AC 87 ms 18496 KiB
01_random_43.txt AC 24 ms 6476 KiB
01_random_44.txt AC 50 ms 9456 KiB
01_random_45.txt AC 6 ms 4408 KiB
02_handmade_46.txt AC 88 ms 18676 KiB
02_handmade_47.txt AC 1 ms 3476 KiB
02_handmade_48.txt AC 33 ms 11044 KiB
02_handmade_49.txt AC 1 ms 3476 KiB
02_handmade_50.txt AC 141 ms 18596 KiB
02_handmade_51.txt AC 38 ms 11024 KiB
02_handmade_52.txt AC 94 ms 18680 KiB
02_handmade_53.txt AC 69 ms 17204 KiB