Submission #20215733
Source Code Expand
#include <bits/stdc++.h> using namespace std; int main(){ int64_t B, C; cin >> B >> C; // 作れる値の区間たち(閉区間) vector<pair<int64_t, int64_t>> PS; // 先頭で-1倍しない、末尾で-1倍しない { int64_t start = B, step = C/2; PS.emplace_back(start-step, start); } // 先頭で-1倍しない、末尾で-1倍する { int64_t start = B, step = (C-1)/2; PS.emplace_back(-start, -(start-step)); } // 先頭で-1倍する、末尾で-1倍しない { int64_t start = -B, step = (C-1)/2; PS.emplace_back(start-step, start); } // 先頭で-1倍する、末尾で-1倍する if(C >= 2){ int64_t start = -B, step = (C-2)/2; PS.emplace_back(-start, -(start-step)); } // 半開区間に直して座圧+imos法。mapを使って実装 map<int64_t, int64_t> mp; for(auto [s, t] : PS){ mp[s]++; mp[t+1]--; } // 座圧した点を小さいほうから見ていって、sumが正である区間の長さを合計する int64_t ans = 0, sum = 0, prv = -8e18; for(auto [pt, val] : mp){ if(sum) ans += pt-prv; prv = pt; sum += val; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - -- - B |
User | betrue12 |
Language | C++ (GCC 9.2.1) |
Score | 400 |
Code Size | 1338 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 3620 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample.txt, sample_2.txt, sample_3.txt, sample_4.txt |
All | 0_1.txt, 0_1000000000000000000.txt, 1000000000000000000_1.txt, 1000000000000000000_1000000000000000000.txt, 1312150450968415_354979173822804784.txt, 252509054433933443_74859962623690081.txt, 335408917861648769_779547116602436426.txt, 489647926824927166_979295853649854331.txt, 489647926824927166_979295853649854332.txt, 489647926824927166_979295853649854333.txt, 522842184971407772_585335723211047202.txt, 645762258982631929_269587449430302156.txt, 84324828731963978_148049062628894325.txt, 891351282707723854_349993004923078537.txt, sample.txt, sample_2.txt, sample_3.txt, sample_4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_1.txt | AC | 9 ms | 3488 KB |
0_1000000000000000000.txt | AC | 2 ms | 3592 KB |
1000000000000000000_1.txt | AC | 2 ms | 3588 KB |
1000000000000000000_1000000000000000000.txt | AC | 2 ms | 3556 KB |
1312150450968415_354979173822804784.txt | AC | 2 ms | 3592 KB |
252509054433933443_74859962623690081.txt | AC | 2 ms | 3592 KB |
335408917861648769_779547116602436426.txt | AC | 1 ms | 3520 KB |
489647926824927166_979295853649854331.txt | AC | 2 ms | 3592 KB |
489647926824927166_979295853649854332.txt | AC | 2 ms | 3492 KB |
489647926824927166_979295853649854333.txt | AC | 2 ms | 3416 KB |
522842184971407772_585335723211047202.txt | AC | 3 ms | 3544 KB |
645762258982631929_269587449430302156.txt | AC | 2 ms | 3492 KB |
84324828731963978_148049062628894325.txt | AC | 2 ms | 3592 KB |
891351282707723854_349993004923078537.txt | AC | 3 ms | 3492 KB |
sample.txt | AC | 2 ms | 3496 KB |
sample_2.txt | AC | 2 ms | 3544 KB |
sample_3.txt | AC | 2 ms | 3620 KB |
sample_4.txt | AC | 2 ms | 3424 KB |