結果
| 問題 | No.1077 Noelちゃんと星々4 |
| コンテスト | |
| ユーザー |
c-yan
|
| 提出日時 | 2020-06-14 12:36:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 593 bytes |
| 記録 | |
| コンパイル時間 | 2,419 ms |
| コンパイル使用メモリ | 198,472 KB |
| 最終ジャッジ日時 | 2025-01-11 04:14:31 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 1 WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*’ {aka ‘long long int*’} [-Wformat=]
13 | scanf("%d", &Y[i]);
| ~^
| |
| int*
| %lld
main.cpp:20:26: warning: left shift count >= width of type [-Wshift-count-overflow]
20 | ll t = 1 << 60;
| ~~^~~~~
main.cpp:26:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
26 | printf("%d\n", *min_element(dp.begin(), dp.end()));
| ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| int long long int
| %lld
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d", &Y[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
using ll = long long;
using namespace std;
int main()
{
int N;
scanf("%d", &N);
vector<ll> Y(N), a(N);
rep(i, N) {
scanf("%d", &Y[i]);
a[i] = Y[i];
}
sort(a.begin(), a.end());
a.erase(unique(a.begin(), a.end()), a.end());
vector<ll> dp(a.size(), 0);
rep(i, N){
ll t = 1 << 60;
rep(j, a.size()){
chmin(t, dp[j] + abs(Y[i] - a[j]));
dp[j] = t;
}
}
printf("%d\n", *min_element(dp.begin(), dp.end()));
return 0;
}
c-yan