# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
893884 |
2023-12-27T16:09:20 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
1158 ms |
43276 KB |
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #pragma GCC optimize("Ofast,unroll-loops,fast-math")
// #pragma GCC target("popcnt")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back
const int mod = ll(1e9)+7; //(b + (a%b)) % b (to mod -1%(10^9+7) correctly in c++ its -1 but its suppose to be 10^9+6
const ll MOD = 998244353; // (a%mod)*(binpow(b,mod-2,mod) = (a/b)%mod
const int N = ll(3e5)+100;
const long long inf = 2e18;
const long double eps = 1e-15L;
ll lcm(ll a, ll b) { return (a / __gcd(a,b))*b; }
ll binpow(ll a, ll b, ll m) { ll res=1; a %= m; while(b>0){ if(b&1)res=(res * a) % m; a=(a * a) % m; b/=2; } return res%m;}
void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
int n, m, o[N], need[N], k, ql[N], qr[N], qa[N], ans[N], bl[N], br[N];
ll f[N];
vector<int> check[N];
vector<int> pos[N];
void update(int p, int x) {
while(p <= m) {
f[p] += x;
p += (p & -p);
}
}
ll get(int p) {
ll res = 0;
while(p >= 1) {
res += f[p];
p -= (p & -p);
}
return res;
}
void Baizho() {
cin>>n>>m;
for(int i = 1; i <= m; i ++) {
cin>>o[i];
pos[o[i]].pb(i);
}
for(int i = 1; i <= n; i ++) cin>>need[i];
cin>>k;
for(int i = 1; i <= k; i ++) cin>>ql[i]>>qr[i]>>qa[i];
for(int i = 1; i <= n; i ++) {
bl[i] = 1, br[i] = k;
}
for(int bin = 0; bin <= 25; bin ++) {
for(int j = 0; j <= max(m, k); j ++) {
f[j] = 0;
check[j].clear();
}
for(int i = 1; i <= n; i ++) {
if(bl[i] <= br[i]) check[(bl[i] + br[i]) / 2].pb(i);
}
for(int i = 1; i <= k; i ++) {
if(ql[i] > qr[i]) {
update(ql[i], qa[i]);
// cout<<ql[i]<<" "<<qa[i]<<" "<<get(ql[i])<<"\n";
update(1, qa[i]);
update(qr[i] + 1, -qa[i]);
} else {
update(ql[i], qa[i]);
if(qr[i] + 1 <= m) update(qr[i] + 1, -qa[i]);
}
for(auto j : check[i]) {
ll res = 0;
// cout<<j<<" "<<i<<"\n";
for(auto p : pos[j]) {
// cout<<p<<" "<<get(p)<<"\n";
res += get(p);
}
// cout<<res<<"\n";
if(need[j] <= res) br[j] = i - 1;
else bl[j] = i + 1;
}
}
}
for(int i = 1; i <= n; i ++) {
if(br[i] + 1 > k) cout<<"NIE\n";
else cout<<br[i] + 1<<"\n";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
// precalc();
int ttt = 1;
// cin>>ttt;
for(int i=1; i<=ttt; i++) {Baizho(); }
}
Compilation message
met.cpp: In function 'void Freopen(std::string)':
met.cpp:35:34: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
met.cpp:35:76: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
25176 KB |
Output is correct |
2 |
Correct |
6 ms |
25176 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
25180 KB |
Output is correct |
2 |
Correct |
5 ms |
25180 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
26032 KB |
Output is correct |
2 |
Correct |
109 ms |
27796 KB |
Output is correct |
3 |
Correct |
92 ms |
27476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
26832 KB |
Output is correct |
2 |
Correct |
97 ms |
27032 KB |
Output is correct |
3 |
Correct |
107 ms |
27848 KB |
Output is correct |
4 |
Correct |
28 ms |
26712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
26512 KB |
Output is correct |
2 |
Correct |
84 ms |
28244 KB |
Output is correct |
3 |
Correct |
51 ms |
25176 KB |
Output is correct |
4 |
Correct |
98 ms |
27848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
25552 KB |
Output is correct |
2 |
Correct |
102 ms |
27012 KB |
Output is correct |
3 |
Correct |
82 ms |
25912 KB |
Output is correct |
4 |
Correct |
109 ms |
29008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1149 ms |
43276 KB |
Output is correct |
2 |
Incorrect |
776 ms |
33852 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1158 ms |
42212 KB |
Output is correct |
2 |
Incorrect |
822 ms |
32716 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |