結果
| 問題 | No.1011 Infinite Stairs |
| コンテスト | |
| ユーザー |
otamay6
|
| 提出日時 | 2020-03-11 16:18:05 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 726 bytes |
| 記録 | |
| コンパイル時間 | 1,781 ms |
| コンパイル使用メモリ | 184,280 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-11 03:29:40 |
| 合計ジャッジ時間 | 4,133 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 4 WA * 20 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:26: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
21 | dp[(i+1)&1][j];
| ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/vector:68,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/queue:69,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:160,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_vector.h:1261:7: note: declared here
1261 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
ソースコード
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
int main(){
int N,K,d;
std::cin>>N>>d>>K;
std::vector<std::vector<ll>> dp(2,std::vector<ll>(N*d+1,0));
std::vector<ll> S(d*N+2,0);
dp[0][0]=1;
for(int i=0;i<N;++i){
for(int j=0;j<=d*i;++j){
S[j+1] = S[j] + dp[i&1][j];
}
for(int j=0;j<=d*(i+1);++j){
int ref=min(j,d*i+1);
if(j<d) dp[(i+1)&1][j]=S[ref];
else dp[(i+1)&1][j]=S[ref]-S[j-d];
dp[(i+1)&1][j];
}
}
std::cout<<dp[N&1][K]<<std::endl;
}
otamay6