# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
956105 |
2024-04-01T05:23:35 Z |
Rifal |
Meteors (POI11_met) |
C++14 |
|
1369 ms |
65536 KB |
#include <bits/stdc++.h>
#include <fstream>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define mod 1000000007
#define INF 1000000001
#define INF2 2000000000
///#define cin fin
///#define cout fout
using namespace std;
double const EPS = 1e-14;
const int P = 1007;
typedef long long ll;
///ofstream fout("herding.out");
///ifstream fin("herding.in");
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
const int Max = 3e5 + 5;
vector<int> where[Max], bi[Max];
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, m; cin >> n >> m;
for(int i = 1; i <= m; i++) {
int x; cin >> x; where[x].push_back(i);
}
ll arr[n+1], ans[n+1]= {};
for(int i = 1; i <= n; i++) cin >> arr[i];
int k; cin >> k; ll qu[k+1][3];
for(int i = 1; i <= k; i++) {
cin >> qu[i][0] >> qu[i][1] >> qu[i][2];
}
pair<int,int> cur[n+1];
for(int i = 1; i <= n; i++) {
cur[i].first = 1; cur[i].second = k;
}
while(true) {
bool check = false;
for(int i = 1; i <= n; i++) {
if(cur[i].first > cur[i].second) continue;
check = true;
int mid = (cur[i].first+cur[i].second)/2;
bi[mid].push_back(i);
}
if(!check) break;
ll fnwk[m+1] = {};
for(int i = 1; i <= k; i++) {
if(qu[i][0] > qu[i][1]) {
for(int j = qu[i][0]; j <= m; j += j&-j) {
fnwk[j] += qu[i][2];
}
for(int j = 1; j <= m; j+= j&-j) {
fnwk[j] += qu[i][2];
}
for(int j = qu[i][1]+1; j <= m; j+= j&-j) {
fnwk[j] -= qu[i][2];
}
}
else {
for(int j = qu[i][0]; j <= m; j+= j&-j) {
fnwk[j] += qu[i][2];
}
for(int j = qu[i][1]+1; j <= m; j+= j&-j) {
fnwk[j] -= qu[i][2];
}
}
// cout << i << 'i' << endl;
for(auto j : bi[i]) {
ll sum1 = 0;
// cout << j << 'j' << endl;
for(auto z : where[j]) {
// cout << z << 'z' << endl;
int pos = z;
ll sum2 = 0;
for(int b = pos; b > 0; b -= b&-b) {
sum2 += fnwk[b];
}
// cout << sum2 << ' ' << "sum2" << endl;
sum1 += sum2;
if(sum1 >= arr[j]) {
// cout << 'Y' << endl;
break;
}
}
// cout << sum1<< ' ' << "sum" << endl;
if(sum1 >= arr[j]) {
cur[j].second = i-1;
ans[j] = i;
} else {
cur[j].first = i+1;
}
}
bi[i].clear();
}
}
for(int i = 1; i <= n; i++) {
if(ans[i] == 0) cout << "NIE" << endl;
else cout << ans[i] << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
14424 KB |
Output is correct |
2 |
Correct |
4 ms |
14436 KB |
Output is correct |
3 |
Correct |
6 ms |
14684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
14424 KB |
Output is correct |
2 |
Correct |
5 ms |
14428 KB |
Output is correct |
3 |
Correct |
6 ms |
14684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
17608 KB |
Output is correct |
2 |
Correct |
82 ms |
20308 KB |
Output is correct |
3 |
Correct |
76 ms |
19700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
19148 KB |
Output is correct |
2 |
Correct |
73 ms |
19028 KB |
Output is correct |
3 |
Correct |
80 ms |
20308 KB |
Output is correct |
4 |
Correct |
23 ms |
17464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
18404 KB |
Output is correct |
2 |
Correct |
65 ms |
20836 KB |
Output is correct |
3 |
Correct |
37 ms |
16216 KB |
Output is correct |
4 |
Correct |
71 ms |
20012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
17308 KB |
Output is correct |
2 |
Correct |
72 ms |
19028 KB |
Output is correct |
3 |
Correct |
56 ms |
17800 KB |
Output is correct |
4 |
Correct |
85 ms |
21584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
733 ms |
46392 KB |
Output is correct |
2 |
Correct |
568 ms |
33116 KB |
Output is correct |
3 |
Correct |
175 ms |
22804 KB |
Output is correct |
4 |
Correct |
1344 ms |
65536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
814 ms |
44844 KB |
Output is correct |
2 |
Correct |
665 ms |
31448 KB |
Output is correct |
3 |
Correct |
153 ms |
22700 KB |
Output is correct |
4 |
Correct |
1369 ms |
65536 KB |
Output is correct |