# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
498087 |
2021-12-24T11:34:10 Z |
vinnipuh01 |
Meteors (POI11_met) |
C++17 |
|
6000 ms |
61220 KB |
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long
using namespace std;
const long long oo = 1000000000000000000;
long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;
/*
ViHHiPuh
(( `'-""``""-'` ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ `;#'#'# - #'#'#;` \
\_)) -----'#'----- ((_/
# --------- #
'# ------- ------ #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
cout << fixed << setprecision(6) << x;
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
freopen ( "sum.in", "r", stdin )
*/
vector <int> vv[ 300002 ];
vector <int> v[ 300002 ];
int L[ 300002 ], R[ 300002 ];
int an[ 300002 ];
int t[ 1200002 ], p[ 1200002 ];
void pus( int v ) {
if ( p[ v ] ) {
p[ v + v ] += p[ v ];
p[ v + v + 1 ] += p[ v ];
t[ v + v ] += p[ v ];
t[ v + v + 1 ] += p[ v ];
p[ v ] = 0;
}
}
void gett( int v, int tl, int tr, int pos ) {
if ( tl > pos || tr < pos )
return;
if ( tl == tr ) {
num += t[ v ];
return;
}
pus( v );
int mid = ( tl + tr ) / 2;
gett( v + v, tl, mid, pos );
gett( v + v + 1, mid + 1, tr, pos );
}
void upd( int v, int tl, int tr, int l, int r ) {
if ( tl > r || tr < l )
return;
if ( tl >= l && tr <= r ) {
t[ v ] += num;
p[ v ] += num;
return;
}
pus( v );
int mid = ( tl + tr ) / 2;
upd( v + v, tl, mid, l, r );
upd( v + v + 1, mid + 1, tr, l, r );
}
main () {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
int a[ m + 1 ];
for ( int i = 1; i <= m; i ++ ) {
cin >> a[ i ];
vv[ a[ i ] ].push_back( i );
}
int b[ n + 1 ];
for ( int i = 1; i <= n; i ++ ) {
cin >> b[ i ];
}
int q;
cin >> q;
int l[ q + 1 ], r[ q + 1 ], x[ q + 1 ];
for ( int i = 1; i <= q; i ++ ) {
cin >> l[ i ] >> r[ i ] >> x[ i ];
}
for ( int i = 1; i <= n; i ++ )
L[ i ] = 1, R[ i ] = q + 1;
ans = 1;
int mid;
while ( ans ) {
ans = 0;
for ( int j = 1; j <= q; j ++ )
v[ j ].clear();
for ( int i = 1; i <= n; i ++ ) {
// cout << i << " - " << L[ i ] << " " << R[ i ] << "\n";
if ( L[ i ] == R[ i ] )
continue;
mid = ( L[ i ] + R[ i ] ) / 2;
v[ mid ].push_back( i );
ans = 1;
}
for ( int j = 1; j <= q; j ++ ) {
num = x[ j ];
if ( l[ j ] <= r[ j ] )
upd( 1, 1, m, l[ j ], r[ j ] );
else
upd( 1, 1, m, 1, r[ j ] ), upd( 1, 1, m, l[ j ], m );
if ( v[ j ].size() == 0 )
continue;
for ( auto i : v[ j ] ) {
num = 0;
for ( auto pos : vv[ i ] ) {
gett( 1, 1, m, pos );
if ( num >= b[ i ] ) {
break;
}
}
// cout << i << " - " << num << "\n";
if ( num >= b[ i ] )
R[ i ] = j;
else
L[ i ] = j + 1;
}
}
for ( int j = 1; j <= q; j ++ ) {
num = -x[ j ];
if ( l[ j ] <= r[ j ] )
upd( 1, 1, m, l[ j ], r[ j ] );
else
upd( 1, 1, m, 1, r[ j ] ), upd( 1, 1, m, l[ j ], m );
}
}
for ( int i = 1; i <= n; i ++ ) {
if ( L[ i ] <= q )
cout << L[ i ] << "\n";
else
cout << "NIE\n";
}
}
Compilation message
met.cpp:89:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
89 | main () {
| ^~~~
met.cpp: In function 'int main()':
met.cpp:115:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
115 | for ( int j = 1; j <= q; j ++ )
| ^~~
met.cpp:117:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
117 | for ( int i = 1; i <= n; i ++ ) {
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
14536 KB |
Output is correct |
2 |
Correct |
15 ms |
14540 KB |
Output is correct |
3 |
Correct |
14 ms |
14540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
14540 KB |
Output is correct |
2 |
Correct |
13 ms |
14460 KB |
Output is correct |
3 |
Correct |
13 ms |
14560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
571 ms |
19500 KB |
Output is correct |
2 |
Correct |
779 ms |
22592 KB |
Output is correct |
3 |
Correct |
730 ms |
21704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
687 ms |
20920 KB |
Output is correct |
2 |
Correct |
719 ms |
20860 KB |
Output is correct |
3 |
Correct |
702 ms |
23120 KB |
Output is correct |
4 |
Correct |
118 ms |
19968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
295 ms |
19924 KB |
Output is correct |
2 |
Correct |
502 ms |
23216 KB |
Output is correct |
3 |
Correct |
327 ms |
15736 KB |
Output is correct |
4 |
Correct |
712 ms |
22292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
682 ms |
18724 KB |
Output is correct |
2 |
Correct |
639 ms |
20960 KB |
Output is correct |
3 |
Correct |
653 ms |
19016 KB |
Output is correct |
4 |
Correct |
718 ms |
24500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6043 ms |
61220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6058 ms |
59412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |