Submission #00029


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
int N;
int A[1111111];
signed main(){
cin>>N;
rep(i,N)cin>>A[i+1],A[i+1]+=A[i];
map<int,int>cnt;cnt[0]=0;
int ma=0;
for(int i=1;i<=N;i++){
if(cnt.find(A[i])!=cnt.end()){
chmax(ma,i-cnt[A[i]]);
}
else{
cnt[A[i]]=i;
}
}
if(ma==0)cout<<"NA"<<endl;
else cout<<ma<<endl;
return 0;
}

ステータス

項目 データ
問題 0006 - Re : Jealousy_of_Parsee
ユーザー名 latte0119
投稿日時 2017-01-29 19:16:49
言語 C++11
状態 Accepted
得点 250
ソースコード長 962 Byte
最大実行時間 843 ms
最大メモリ使用量 71376 KB

セット

セット 得点 Cases
1 All 250 / 250 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01_easy AC 17 ms 480 KB
1
Input02_easy AC 51 ms 464 KB
1
Input03_easy AC 17 ms 444 KB
1
Input04_easy AC 15 ms 416 KB
1
Input05_easy AC 23 ms 384 KB
1
Input06_easy AC 15 ms 492 KB
1
Input07_easy AC 22 ms 588 KB
1
Input08_easy AC 15 ms 560 KB
1
Input09_easy AC 19 ms 644 KB
1
Input10_easy AC 17 ms 680 KB
1
Input11_normal AC 27 ms 1240 KB
1
Input12_normal AC 23 ms 2056 KB
1
Input13_normal AC 31 ms 2692 KB
1
Input14_normal AC 33 ms 3396 KB
1
Input15_normal AC 35 ms 3916 KB
1
Input16_normal AC 38 ms 3892 KB
1
Input17_normal AC 34 ms 3908 KB
1
Input18_normal AC 38 ms 4132 KB
1
Input19_normal AC 32 ms 3972 KB
1
Input20_normal AC 40 ms 3944 KB
1
Input21_hard AC 105 ms 14456 KB
1
Input22_hard AC 178 ms 29224 KB
1
Input23_hard AC 302 ms 43152 KB
1
Input24_hard AC 323 ms 49292 KB
1
Input25_hard AC 422 ms 63144 KB
1
Input26_hard AC 542 ms 67964 KB
1
Input27_hard AC 502 ms 68988 KB
1
Input28_hard AC 532 ms 68612 KB
1
Input29_hard AC 505 ms 69120 KB
1
Input30_hard AC 506 ms 69452 KB
1
Input31_omake AC 843 ms 71376 KB
1
Input32_omake AC 111 ms 8864 KB
1
Input33_omake AC 798 ms 71188 KB
1
Input34_omake AC 719 ms 55656 KB
1
Input35_omake AC 640 ms 40248 KB
1