結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-03-02 01:52:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 632 bytes |
| コンパイル時間 | 539 ms |
| コンパイル使用メモリ | 59,108 KB |
| 最終ジャッジ日時 | 2024-11-14 19:00:35 |
| 合計ジャッジ時間 | 1,055 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:9: error: ‘vector’ was not declared in this scope
9 | vector<int> x(n);
| ^~~~~~
main.cpp:4:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
3 | #include <unordered_map>
+++ |+#include <vector>
4 | using namespace std;
main.cpp:9:16: error: expected primary-expression before ‘int’
9 | vector<int> x(n);
| ^~~
main.cpp:10:21: error: ‘x’ was not declared in this scope
10 | for(int& v: x) cin>>v;
| ^
main.cpp:11:20: error: ‘x’ was not declared in this scope
11 | sort(begin(x), end(x));
| ^
main.cpp:15:38: error: template argument 2 is invalid
15 | unordered_map<int, vector<int>> a;
| ^~
main.cpp:15:38: error: template argument 5 is invalid
main.cpp:16:24: error: invalid types ‘int[int]’ for array subscript
16 | for(int v: x) a[v%d].push_back(v/d);
| ^
main.cpp:19:22: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
19 | for(auto& v: a) {
| ^
| std::begin
In file included from /usr/include/c++/11/string:54,
from /usr/include/c++/11/bits/locale_classes.h:40,
from /usr/include/c++/11/bits/ios_base.h:41,
from /usr/include/c++/11/ios:42,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from main.cpp:1:
/usr/include/c++/11/bits/range_access.h:90:5: note: ‘std::begin’ declared here
90 | begin(_Tp (&__arr)[_Nm]) noexcept
| ^~~~~
main.cpp:19:22: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
19 | for(auto& v: a) {
|
ソースコード
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main()
{
int n, d, t;
while (cin>>n>>d>>t) {
vector<int> x(n);
for(int& v: x) cin>>v;
sort(begin(x), end(x));
for(int i=1;i<n;++i) x[i]-=x[0];
x[0]=0;
unordered_map<int, vector<int>> a;
for(int v: x) a[v%d].push_back(v/d);
long long res=0;
for(auto& v: a) {
auto& w=v.second;
res+=2*t+1;
for(int i=1;i<w.size();++i)
res+=2*t+1-max(0, w[i-1]+t+1-(w[i]-t));
}
cout<<res<<endl;
}
}
hogeover30