結果
問題 | No.2142 Segment Zero |
ユーザー | ゾビオ |
提出日時 | 2022-12-03 00:14:52 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 2,247 bytes |
コンパイル時間 | 4,940 ms |
コンパイル使用メモリ | 308,388 KB |
実行使用メモリ | 19,020 KB |
最終ジャッジ日時 | 2024-10-10 02:39:36 |
合計ジャッジ時間 | 6,545 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 11 ms
18,896 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 12 ms
18,968 KB |
testcase_04 | AC | 13 ms
18,968 KB |
testcase_05 | AC | 12 ms
18,792 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 14 ms
18,780 KB |
testcase_08 | AC | 11 ms
18,784 KB |
testcase_09 | AC | 11 ms
18,884 KB |
testcase_10 | AC | 12 ms
18,924 KB |
testcase_11 | AC | 13 ms
18,844 KB |
testcase_12 | AC | 11 ms
18,924 KB |
testcase_13 | AC | 12 ms
18,880 KB |
testcase_14 | AC | 12 ms
18,848 KB |
testcase_15 | AC | 13 ms
19,020 KB |
testcase_16 | AC | 12 ms
18,844 KB |
testcase_17 | AC | 11 ms
16,128 KB |
testcase_18 | AC | 6 ms
7,040 KB |
testcase_19 | AC | 5 ms
6,816 KB |
testcase_20 | AC | 8 ms
11,964 KB |
testcase_21 | AC | 8 ms
12,976 KB |
testcase_22 | AC | 9 ms
14,560 KB |
testcase_23 | AC | 5 ms
6,816 KB |
testcase_24 | AC | 5 ms
8,228 KB |
testcase_25 | AC | 7 ms
9,240 KB |
testcase_26 | AC | 9 ms
14,136 KB |
testcase_27 | AC | 9 ms
14,756 KB |
testcase_28 | AC | 7 ms
10,432 KB |
testcase_29 | AC | 6 ms
11,960 KB |
testcase_30 | AC | 8 ms
14,432 KB |
testcase_31 | AC | 10 ms
14,060 KB |
testcase_32 | AC | 7 ms
7,936 KB |
testcase_33 | AC | 4 ms
6,820 KB |
testcase_34 | AC | 7 ms
9,276 KB |
testcase_35 | AC | 12 ms
18,480 KB |
testcase_36 | AC | 5 ms
6,816 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> // AtCoder using namespace std; using namespace atcoder; // AtCoder using uint = unsigned int; using ll = long long; using ull = unsigned long long; using ld = long double; using mint = modint998244353; // AtCoder using vll = vector<long long>; using vvll = vector<vector<long long>>; using vvvll = vector<vector<vector<long long>>>; using vvvvll = vector<vector<vector<vector<long long>>>>; using dll = deque<long long>; using ddll = deque<deque<long long>>; using dddll = deque<deque<deque<long long>>>; using ddddll = deque<deque<deque<deque<long long>>>>; using pll = pair<long long, long long>; using vpll = vector<pair<long long, long long>>; using vvpll = vector<vector<pair<long long, long long>>>; #define rep(i, n) for (long long i = 0; i < n; i++) #define reps(i, n) for (long long i = 1; i <= n; i++) #define rrep(i, n) for (long long i = n - 1; i >= 0; i--) #define rreps(i, n) for (long long i = n; i >= 1; i--) #define reep(i, a, b) for (long long i = a; i < b; i++) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define PI acos(-1.0) #define YES printf("Yes\n"), exit(0) #define NO printf("No\n"), exit(0) constexpr long long MOD = 998244353LL; constexpr long long INF = (1LL << 60); template<class T> void setcout(T n) {cout << setprecision(n) << fixed;} template<class T> void arrcout(T &a) { for(size_t i = 0; i < a.size(); i++) cout << (i ? " " : "") << a.at(i); cout << endl; } template<class T> void arrcout2(T &a) { for(size_t i = 0; i < a.size(); i++) { for(size_t j = 0; j < a[i].size(); j++) cout << (j ? " " : "") << a.at(i).at(j); cout << endl;} } template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") int main() { ll n, k; cin >> n >> k; vll a(n); iota(all(a), 1ll); vll rui(n + 1); rep(i, n) rui[i + 1] = rui[i] + a[i]; ll ans = 2; ll r = 0; rep(l, n) { //尺取り法 while(r < n && rui.back() - rui[r] + rui[l] > k) r++; if(rui.back() - rui[r] + rui[l] == k) ans = 1; } cout << ans << endl; }