結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
data9824
|
| 提出日時 | 2015-06-15 04:03:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,130 bytes |
| コンパイル時間 | 766 ms |
| コンパイル使用メモリ | 81,964 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 10:12:00 |
| 合計ジャッジ時間 | 1,302 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
int main() {
int n;
long long d, t;
cin >> n >> d >> t;
vector<long long> x(n);
for (int i = 0; i < n; ++i) {
cin >> x[i];
}
map<long long, set<long long> > positions;
for (int i = 0; i < n; ++i) {
positions[(0x80000000LL + x[i]) % d].insert(0x80000000LL + x[i]);
}
long long result = 0LL;
for (map<long long, set<long long> >::const_iterator it = positions.begin();
it != positions.end();
++it) {
vector<pair<long long, long long> > ranges;
for (set<long long>::const_iterator itSet = it->second.begin();
itSet != it->second.end();
++itSet) {
ranges.push_back(make_pair(*itSet / d - t, *itSet / d + t));
}
if (!ranges.empty()) {
long long lower = ranges.front().first;
long long upper = ranges.front().second;
for (size_t i = 1; i < ranges.size(); ++i) {
if (upper < ranges[i].first) {
result += upper - lower + 1;
lower = ranges[i].first;
}
upper = ranges[i].second;
}
result += upper - lower + 1;
}
}
cout << result << endl;
return 0;
}
data9824