結果

問題 No.8046 yukicoderの過去問
コンテスト
ユーザー ciel
提出日時 2019-04-07 21:01:15
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 441 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 349 ms
コンパイル使用メモリ 51,072 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2026-06-07 10:14:38
合計ジャッジ時間 4,144 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d%d",&K,&N);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:13:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         for(int i=0,y;i<N;i++)scanf("%d",&y),x[y]=1;
      |                               ~~~~~^~~~~~~~~

ソースコード

diff #
raw source code

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <vector>
#include <cstdio>
using namespace std;

const int M=1000000007;
int main(){
	int K,N;
	scanf("%d%d",&K,&N);
	vector<int> k(K+1);k[0]=1;
	vector<int> x(K);
	for(int i=0,y;i<N;i++)scanf("%d",&y),x[y]=1;
	for(int l=0;l<K;l++){
		int v=k[l];
		for(int i=0;l+i<=K;i++){
			k[l+i]+=x[i]*v;
			//if(k[l+i]>=M)k[l+i]-=M;
			k[l+i]-=M*(k[l+i]>=M);
		}
	}
	printf("%d\n",k[K]);
}
0