Skip to content

Commit 74be097

Browse files
committed
.
1 parent bd8b5e9 commit 74be097

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
"type_traits": "cpp",
4646
"typeindex": "cpp"
4747
},
48-
"competitive-programming-helper.firstTime": false
48+
"competitive-programming-helper.firstTime": false,
49+
"compile-hero.disable-compile-files-on-did-save-code": true
4950
}

a.out

26.6 KB
Binary file not shown.

int.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* |\ | | ||\ \ /(_~ |~)|_~|\/||_~|\/||~)|_~|~)
2+
|~\|_|/\||~\ | ,_) |~\|__| ||__| ||_)|__|~\
3+
4+
\ //~\| | |\ |~)|_~ | ||\ ||/~\| ||_~
5+
| \_/\_/ |~\|~\|__ \_/| \||\_X\_/|__
6+
(J U S T L I K E E V E R Y O N E E L S E !)
7+
8+
__ ,..---.._
9+
+''''`--''-..`--..__
10+
.\ _,/:i--._`:-:+._`.``-._
11+
/`.._,,' \ `-.``--:.b....=.
12+
|`..__,,..`. '`.__::i--.-::_
13+
)- .....--i'\.. --+`'''-'
14+
,' .'.._,.-'|._-b\
15+
/,'<' V `oi| \ _.
16+
|/ -|,--.." ,'-. ||\.. _.,;:'_<'
17+
''/ | . ' |\||'\ /-'_/' `.
18+
|,','| , . .-.|:.`. + .,:.. |
19+
._,:'/ /-\ '^' -Y"\ |.| || /,+8d| |
20+
.|/,'| |/':: ':=:' ,'| | | \|| "+)=' |
21+
|+,';' /|_/ \ _/ \b':.\ \'| .|| ,'
22+
,,:-i''_i' | ``-.Y',. ,|`: | \;- | |_,'
23+
__ |'| |i:'._ ,' ,' ,; | |-)-' __--:b__
24+
.P| | |/,'|\ - ._ / / _,Y- ,:/' `. `'".._
25+
,'|| -','' | ._i._ `':| ,..,' ,Y;' \ `- ._
26+
|||||,.. | \ '-.._ _,' / _,b-' `. '-.
27+
||||P..i, .| '....,-' _,'''''-''' ' _,.. `\
28+
+'` <'/ |`-.....---' ._ ,._
29+
| | ,'``,:-''''/,--`.
30+
Y|.b_,,: | || ,;,Y' / |.
31+
,' /'----' .'| .. | | '" .`Y' .,-b_....;;,.
32+
|+|,' | | \., ' ,' `:. _ ,/__` _=: _,'``-
33+
/ +,' | /\_........:.' '"----:::::'Y .'.| |||
34+
|' ' .'/- \ /'|| || | |||
35+
||| /| \L /'|| ||/ | |||
36+
`.| ,'/ .| / ,'||/o;/ |||
37+
`..._,, | |/| ' |||
38+
``-' | |, |||
39+
| ,. | |||
40+
,=--------.... | "" | |||
41+
,/,'. i=..+._ ,.. '..;---:::''- | |
42+
'/| __....b `-''`---....../.,Y'''''j:.,.._ | `._
43+
.' _.Y.-' `.. ii:,'--------' | :-+. .| | b\
44+
| .=_,.---'''''--...:..--:' / _..-----..:= | | '|\
45+
| '-''`'--- ---'_,,,--'' `,.. | | \.
46+
\ . ,' _,--'' :dg: _,/ ||| | \
47+
`::b\` _,-i,-' ,..---' ,|:| | _|
48+
`'--.:-._ ____,,,;.,'' `--._ '''''''' |'|' .' '
49+
``'--....Y''-' `''--..._..____._____...,' | 'o-'
50+
`''''`'''i==_+=_=i__
51+
||'''- ' `.
52+
`-.......-''
53+
*/
54+
#include<bits/stdc++.h>
55+
using namespace std;
56+
57+
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
58+
#define LL long long
59+
#define mod 1000000007
60+
#define all(v) v.begin(),v.end()
61+
#define pr(v) pair<v,v>
62+
#define pb push_back
63+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
64+
#define ROF(i, j, k) for (auto i=j ; i>=k ; i--)
65+
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
66+
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
67+
68+
const long long INF = 1e18;
69+
const long long MAX = 2e5+10;
70+
int solve(int n, vector<int> &a) {
71+
LL sum = 0;
72+
FOR(i,0,n ) sum+=a[i];
73+
if(sum%3!=0) return 0;
74+
sum/=3;
75+
LL s=0;int ans = 0;
76+
map<LL,int>m;
77+
ROF(i,n-1,0) s+=a[i],m[s]++;
78+
LL p=0;
79+
FOR(i,0,n-1) {
80+
m[s]--; s-=a[i];
81+
p+=a[i];
82+
if(p==sum){
83+
cout<<i <<" ";
84+
ans+=m[sum];
85+
}
86+
}
87+
88+
return ans;
89+
}
90+
int main(){
91+
fastio;
92+
int t=1;// cin>>t;
93+
while(t--){
94+
int n; cin>>n; vector<int>v(n);
95+
FOR(i,0,n) cin>>v[i];
96+
cout<<solve(n,v);
97+
}
98+
}

0 commit comments

Comments
 (0)