# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
890460 |
2023-12-21T09:44:20 Z |
armashka |
Meteors (POI11_met) |
C++17 |
|
6000 ms |
16864 KB |
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
void dgb_out() { cerr << "\n"; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << " " << H; dgb_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file(s) freopen(s".in", "r", stdin);freopen(s".out", "w", stdout);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ft first
#define sd second
#define ll long long
#define pll pair<ll,ll>
const int N = 1e6 + 10;
const int M = 2e7 + 5;
const int B = 316;
const ll msize = 2;
const ll mod1 = 1e9 + 7;
const ll mod2 = 998244353;
const long double Phi = acos(-1);
const long long inf = 3e18;
ll binmul(ll x, ll ti, ll m);
ll binpow(ll x, ll ti, ll m);
struct Query {
ll l, r, x;
} q[N];
ll n, m, k, a[N], b[N], sc[N];
bool check(int mid, int pos) {
for (int i = 1; i <= m; ++ i) sc[i] = 0;
for (int i = 1; i <= mid; ++ i) {
if (q[i].l <= q[i].r) {
sc[q[i].l] += q[i].x;
sc[q[i].r + 1] -= q[i].x;
} else {
sc[q[i].l] += q[i].x;
sc[1] += q[i].x;
sc[q[i].r + 1] -= q[i].x;
}
}
ll sum = 0;
for (int i = 1; i <= m; ++ i) {
sc[i] += sc[i - 1];
if (a[i] == pos) sum += sc[i];
}
return (sum >= b[pos]);
}
const void solve() {
cin >> n >> m;
for (int i = 1; i <= m; ++ i) cin >> a[i];
for (int i = 1; i <= n; ++ i) cin >> b[i];
cin >> k;
for (int i = 1; i <= n; ++ i) cin >> q[i].l >> q[i].r >> q[i].x;
for (int i = 1; i <= n; ++ i) {
int l = 1, r = k, ans = -1;
while (l <= r) {
int mid = (l + r) / 2;
if (check(mid, i)) r = mid - 1, ans = mid;
else l = mid + 1;
}
if (ans == -1) cout << "NIE\n";
else cout << ans << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
srand(time(NULL));
//file("monsters");
int tt = 1;
// cin >> tt;
for (int i = 1; i <= tt; ++ i) {
solve();
}
return 0;
}
// Template functions
ll binmul(ll x, ll ti, ll m) { ll res = 0;while (ti){if(ti & 1)res += x;x += x;ti >>= 1; x %= m; res %= m;} return res;}
ll binpow(ll x, ll ti, ll m) { ll res = 1;while (ti){if(ti & 1)res=binmul(res,x,m);x=binmul(x,x,m);ti >>= 1; x %= m; res %= m;} return res;}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
6744 KB |
Output is correct |
2 |
Correct |
5 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
16 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6088 ms |
8828 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6003 ms |
8828 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6046 ms |
9044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1157 ms |
8824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6009 ms |
16840 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6033 ms |
16864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |