?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
81682831 |
Practice: ishansourav7 |
466C - 30 | C++14 (GCC 6-32) | Time limit exceeded on test 6 | 2000 ms | 1320 KB | 2020-05-28 10:54:20 | 2020-05-28 10:54:20 |
#include <bits/stdc++.h> #define ll long long using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n; cin>>n; ll a[n+1]; a[0] = 0; for(int i=1; i<=n; i++){ cin>>a[i]; a[i] += a[i-1]; } ll total = a[n]; if(total % 3){ cout<<0<<endl; return 0; } vector <int> blk1; int cnt = 0; for(int i=1; i<n-1; i++){ if(a[i] == total/3){ cnt++; blk1.push_back(i); } } int cnt2 = 0; for(int idx: blk1){ for(int i=idx+1; i<n; i++){ if(a[i] - a[idx] == total/3 && a[n] - a[i] == total/3) cnt2++; } } cout<<cnt2<<endl; return 0; }
?
?
?
?