結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-24 23:50:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,835 bytes |
| コンパイル時間 | 2,123 ms |
| コンパイル使用メモリ | 167,572 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 00:51:12 |
| 合計ジャッジ時間 | 3,458 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 17 |
コンパイルメッセージ
main.cpp: In function ‘void {anonymous}::toc()’:
main.cpp:24:45: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘std::chrono::duration<long int, std::ratio<1, 1000> >::rep’ {aka ‘long int’} [-Wformat=]
24 | void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); }
| ~~~^
| |
| long long int
| %ld
main.cpp: In function ‘int main()’:
main.cpp:121:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=]
121 | printf("%d\n%d %d\n",((ll)best)*kk,besti,bestj);
| ~^ ~~~~~~~~~~~~~
| | |
| int ll {aka long long int}
| %lld
main.cpp:100:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
100 | scanf("%d", daikon + i);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007ll
void printbit(int u) { if (u == 0)cout << 0; else { int s = 0, k = 0; for (; 0<u; u >>= 1, k++)s = (s << 1) | (u & 1); for (; 0<k--; s >>= 1)cout << (s & 1); } }
#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())
namespace {
std::chrono::system_clock::time_point t;
void tic() { t = TIME; }
void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); }
std::chrono::system_clock::time_point tle = TIME;
void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); }
}
template<typename T1, typename T2>
ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; }
template<typename T, T idt = 0x7FFFFFFF, typename Compare = std::less<T>>
class segtree {
size_t size;
vector<T> data;
Compare cp;
const T& selector(const T& x, const T& y) const {
return cp(x, y) ? x : y;
}
public:
segtree(size_t n) {
size = 1;
while (size<n) size <<= 1;
data.resize(size * 2);
}
void fill(const T& e) {
std::fill(data.begin(), data.end(), e);
}
const T& operator[](size_t index) const {
return data[size - 1 + index];
}
void update(size_t index, const T& e) {
index += size - 1;
data[index] = e;
while (0 < index) {
index = (index - 1) / 2; // 親へ移動
data[index] = selector(data[index * 2 + 1], data[index * 2 + 2]); // iの子を参照して、d[i]を更新する
}
}
T query(size_t begin, size_t end, size_t ptr = 0, size_t rangebegin = 0, size_t rangeend = 0) const {
if (rangeend <= rangebegin) { rangeend = size; }
if (rangeend <= begin || end <= rangebegin) return idt;
if (begin <= rangebegin && rangeend <= end) return data[ptr];
size_t rangemid = (rangebegin + rangeend) / 2;
return selector(query(begin, end, ptr * 2 + 1, rangebegin, rangemid), query(begin, end, ptr * 2 + 2, rangemid, rangeend));
}
};
int width, height;
int n, dd, kk;
int daikon[100010];
struct compare{
bool operator ()(const int& l, const int& r) const {
if (l == BIGINT) return false;
if (r == BIGINT) return true;
return daikon[l] < daikon[r];
}
};
int main() {
int i, j, k, l;
int x, y, a, b;
cin >> n >> dd >> kk;
for (i = 0; i < n; ++i) {
scanf("%d", daikon + i);
}
segtree<int, BIGINT, compare> seg(n);
seg.fill(BIGINT);
int best = 0;
int besti = -1, bestj;
for (i = 0; i < n; ++i) {
seg.update(i, i);
int les = seg.query(max(0, i - dd), i);
if (les != BIGINT && best < daikon[i] - daikon[les]) {
best = daikon[i] - daikon[les];
besti = les;
bestj = i;
}
}
if (besti == -1) {
cout << 0 << endl;
}
else {
printf("%d\n%d %d\n",((ll)best)*kk,besti,bestj);
}
return 0;
}