제출 #891589

#제출 시각아이디문제언어결과실행 시간메모리
891589_no_nameSum Zero (RMI20_sumzero)C++17
22 / 100
1034 ms880 KiB
//Ai_2007 //Make the impossible possible #include<bits/stdc++.h> #define ll long long #define fo(i,m,n) for(int i=m; i<=n; i++) #define fod(i,m,n) for(int i=m; i>=n; i--) #define fi first #define se second #define Nmax 1000001 #define pb push_back #define pii pair<int,int> using namespace std; const int N=4e5+5; int n,q,a[N]; //map<ll,vector<int>> m; ll cur=0; void solve() { cin>>n; fo(i,1,n) cin>>a[i]; cin>>q; fo(i,1,q){ int l,r,ans=0; cin>>l>>r; cur=0; set<ll> s; s.insert(0); fo(j,l,r){ cur+=a[j]; if(s.find(cur)!=s.end()){ ans++; s.clear(); s.insert(0); cur=0; } else s.insert(cur); } cout<<ans<<"\n"; } } main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sumzero.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...