結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2014-11-19 23:49:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,044 bytes |
| コンパイル時間 | 527 ms |
| コンパイル使用メモリ | 45,228 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 09:57:35 |
| 合計ジャッジ時間 | 889 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d %lld %lld", &N, &D, &T);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:16:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | for(int i=0;i<N;i++){scanf("%lld", &xs[i]);}
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <algorithm>
typedef long long ll;
typedef std::pair<ll,ll> P;
int N;
ll D, T;
ll xs[100];
bool used[100];
int main(){
scanf("%d %lld %lld", &N, &D, &T);
for(int i=0;i<N;i++){scanf("%lld", &xs[i]);}
std::sort(xs, xs+N);
ll res = 0ll;
for(int i=0;i<N;i++){
if(used[i]){continue;}
used[i] = true;
ll xi = xs[i];
std::vector<P> ps;
for(int j=i;j<N;j++){
if((xs[j] - xi) % D == 0){
int mid = (xs[j]-xi) / D;
ps.push_back(std::make_pair(mid-T, mid+T));
used[j] = true;
}
}
int size = ps.size();
for(int i=0,j=0;i<size;){
P p = ps[i];
while(j < size && ps[j].first <= p.second){
p.second = ps[j].second;
j += 1;
}
res += p.second - p.first + 1;
i = j;
}
}
printf("%lld\n", res);
}
tottoripaper