# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
313807 |
2020-10-17T06:11:55 Z |
vivaan_gupta |
Vudu (COCI15_vudu) |
C++14 |
|
1000 ms |
65540 KB |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll int
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
// #define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
using namespace std;
const ll INF = 1e12;
const ll N =(2e6+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
map<int, int> M;
ll cnt = 1;
ll bit[N];
void upd(int idx){
while(idx <= cnt){
bit[idx]++;
idx += (idx&(-idx));
}
}
ll query(int idx){
ll ans =0;
while(idx >= 1){
ans += bit[idx];
idx -= (idx&(-idx));
}
return ans;
}
void solve() {
// you should actually read the stuff at the bottom
int n;
cin >> n;
int a[n+1];
FOR(i,1,n+1) cin >> a[i];
int p;
cin >> p;
int pre[n+1];
pre[0] = 0;
FOR(i,1,n+1) pre[i] = pre[i-1] + a[i];
ll ans =0;
set<ll> gg;
FOR(i,1,n+1){
gg.in(pre[i] - p*i);
gg.in(pre[i-1] - p*i + p);
}
for(auto x:gg){
M[x] = cnt;
cnt++;
}
cnt--;
assert(cnt <= 2e6);
int lol[n+1],lol2[n+1];
FOR(i,1,n+1) lol[i] = M[pre[i] - p*i],lol2[i] = M[pre[i-1] - p*i + p];
// ROF(i,1,n+1){
// upd(lol[i]);
// int tot = n-i+1;
// tot -= query(lol2[i] - 1);
// ans += tot;
// }
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
// freopen(".in","r",stdin);freopen(".out","w",stdout);
ll tt=1;
// cin >> tt;
while(tt--){
solve();
}
}
Compilation message
vudu.cpp:49:16: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+12' to '2147483647' [-Woverflow]
49 | const ll INF = 1e12;
| ^~~~
vudu.cpp: In function 'void solve()':
vudu.cpp:93:6: warning: variable 'lol' set but not used [-Wunused-but-set-variable]
93 | int lol[n+1],lol2[n+1];
| ^~~
vudu.cpp:93:15: warning: variable 'lol2' set but not used [-Wunused-but-set-variable]
93 | int lol[n+1],lol2[n+1];
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1152 KB |
Output isn't correct |
2 |
Incorrect |
4 ms |
896 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
896 KB |
Output isn't correct |
4 |
Execution timed out |
1054 ms |
48616 KB |
Time limit exceeded |
5 |
Execution timed out |
1103 ms |
58360 KB |
Time limit exceeded |
6 |
Execution timed out |
1087 ms |
46304 KB |
Time limit exceeded |
7 |
Execution timed out |
1092 ms |
50680 KB |
Time limit exceeded |
8 |
Execution timed out |
1080 ms |
65540 KB |
Time limit exceeded |
9 |
Execution timed out |
1092 ms |
50168 KB |
Time limit exceeded |
10 |
Execution timed out |
1088 ms |
54536 KB |
Time limit exceeded |