結果
問題 |
No.1148 土偶Ⅲ
|
ユーザー |
|
提出日時 | 2020-08-06 04:25:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 493 bytes |
コンパイル時間 | 2,417 ms |
コンパイル使用メモリ | 200,056 KB |
最終ジャッジ日時 | 2025-01-12 15:15:22 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | int n,w; scanf("%d%d",&n,&w); | ~~~~~^~~~~~~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n,w; scanf("%d%d",&n,&w); vector<int> a(n); rep(i,n) scanf("%d",&a[i]); int ans=0,dup=0; lint sum=0; map<int,int> f; for(int l=0,r=0;l<n;){ while(r<n && sum<=w && dup==0){ sum+=a[r]; ++f[a[r]]; if(f[a[r]]==2) dup++; r++; } ans=max(ans,r-l-1); sum-=a[l]; --f[a[l]]; if(f[a[l]]==1) dup--; l++; } printf("%d\n",ans); return 0; }