# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
670407 |
2022-12-08T23:58:28 Z |
raypeng1729 |
Sails (IOI07_sails) |
C++17 |
|
1000 ms |
5068 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
const int N = 1e5 + 2, INF = 1e9 + 1, MOD = 1e9 + 7, K = __lg(N) + 1;
struct BIT{
int n;
vector<int> v;
BIT(){v.assign(N, 0);}
void add(int i, int x){
for(; i < N; i += i & (-i)) v[i] += x;
}
int qry(int i){
int ret = 0;
for(; i > 0; i -= i & (-i)) ret += v[i];
return ret;
}
};
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
int a[n], b[n];
for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
int st[n + 2]{}, en[n + 2]{};
st[0] = 1, en[0] = n;
BIT bit;
for(int i = 0; i < n; i++){
int cur = a[i];
while(b[i]){
int x = bit.qry(cur);
int y = min(b[i], a[i] - st[x] + 1); b[i] -= y;
bit.add(st[x], 1), bit.add(st[x] + y, -1);
cur = st[x] - 1;
if(st[x + 1] == 0) st[x + 1] = st[x];
en[x + 1] = max(en[x + 1], st[x] + y - 1);
st[x] = st[x] + y;
}
}
int ans = 0;
for(int i = 1; i <= n; i++){
int x = bit.qry(i);
ans += x * (x - 1) / 2;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1090 ms |
980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
1108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
1108 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1087 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
2012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
2900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
4044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1028 ms |
4684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1065 ms |
5068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |