//gm --- akezhon
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define tm (tl+tr)/2
#define TL v+v, tl, tm
#define TR v+v+1, tm+1, tr
#define DA l <= tl && tr <= r
#define NET r < tl || tr < l
#define double long double
using namespace std;
const int N=1e3+7;
const int M=1e9+7;
const int inf=1e9;
int n, m, k;
int a[N];
int b[N];
int p[N][N];
struct qu{
int l, r, p;
}f[N];
struct lol{
int l, r, m, ans;
}c[N];
void AlemAmenov(){
cin >> n >> m;
for(int i=1; i <= m; i++){
cin >> a[i];
for(int j=1; j <= n; j++){
p[i][j] = p[i-1][j];
}
p[i][a[i]]++;
}
for(int i=1; i <= n; i++){
cin >> b[i];
}
cin >> k;
for(int i=1; i <= n; i++){
c[i].l = 1;
c[i].r = k;
}
for(int i=1; i <= k; i++){
cin >> f[i].l >> f[i].r >> f[i].p;
}
for(int gg=1; gg <= 20; gg++){
for(int i=1; i <= n; i++){
c[i].m = (c[i].l + c[i].r)/2;
if(c[i].l <= c[i].r){
int cnt=0;
for(int j=1; j <= c[i].m; j++){
if(f[j].l <= f[j].r){
cnt += (p[f[j].r][i] - p[f[j].l-1][i])*f[j].p;
}
else {
cnt += p[f[j].r][i]*f[j].p;
cnt += (p[m][i]-p[f[j].l-1][i])*f[j].p;
}
}
if(b[i] <= cnt)c[i].ans = c[i].m, c[i].r = c[i].m-1;
else c[i].l = c[i].m+1;
}
}
}
for(int i=1; i <= n; i++){
if(c[i].ans)cout << c[i].ans << '\n';
else cout << "NIE\n";
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("promote.in", "r", stdin);
// freopen("promote.out", "w", stdout);
int RealName=1;
// cin >> RealName;
// int C=0;
while(RealName--){
// cout << "Case " << ++C << ":\n";
AlemAmenov();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7768 KB |
Output is correct |
2 |
Correct |
11 ms |
8284 KB |
Output is correct |
3 |
Correct |
4 ms |
7772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8028 KB |
Output is correct |
2 |
Correct |
3 ms |
8028 KB |
Output is correct |
3 |
Correct |
12 ms |
8284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
16476 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
16476 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
16476 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
8316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
49 ms |
16464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
48 ms |
16600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |