#include <bits/stdc++.h>
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define a() a + 1, a + n + 1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef string S;
typedef double ld;
typedef long double lld;
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const int INF = 1e9 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const ld eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
return (a.second < b.second);
}
void pre (ll a) {
cout << fixed << setprecision(a);
return;
}
ll n, m;
ll a[N], indeed[N];
ll col[N], cnt[N];
inline void Solution () {
cin >> n >> m;
for (int i = 1; i <= m; ++ i) {
cin >> a[i];
}
for (int i = m + 1; i <= m * 2; ++ i) {
a[i] = a[i - m];
}
for (int i = 1; i <= n; ++ i) {
ll x;
cin >> x;
indeed[i] = x;
}
ll q;
cin >> q;
while (q --) {
ll l, r, ves;
cin >> l >> r >> ves;
if (l > r) {
for (int i = l; i <= r + m; ++ i) {
if (indeed[a[i]] > 0) {
indeed[a[i]] -= ves;
col[a[i]] = 1;
}
}
for (int i = 1; i <= n; ++ i) {
if (col[i] == 1) cnt[i] ++;
col[i] = 0;
}
} else {
for (int i = l; i <= r; ++ i) {
if (indeed[a[i]] > 0) {
indeed[a[i]] -= ves;
col[a[i]] = 1;
}
}
for (int i = 1; i <= n; ++ i) {
if (col[i]) cnt[i] ++;
col[i] = 0;
}
}
}
for (int i = 1; i <= n; ++ i) {
if (indeed[i] > 0) {
cout << "NIE\n";
continue;
}
cout << cnt[i] << '\n';
}
return;
}
int main () {
Zymraq();
Solution ();
exit (0);
}/*
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
890 ms |
1188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2081 ms |
1324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2440 ms |
1456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2145 ms |
1116 KB |
Output is correct |
2 |
Incorrect |
5109 ms |
1356 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6015 ms |
7240 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6034 ms |
6980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |