| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1007865 | christinelynn | Lasers (NOI19_lasers) | C++17 | 205 ms | 44100 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define fi first
#define sec second
#define endl '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 998244353;
const ll N = 5e5 + 5;
const ll INF = 1e18;
vector<ll>vec[N];
int32_t main(){
cin.tie(0)->sync_with_stdio(0);
int tc = 1;
// cin >> tc;
while(tc--){
ll n,q; cin >> n >> q;
for(int i=1;i<=q;i++){
ll a; cin >> a;
for(int j=1;j<=a;j++){
ll x; cin >> x;
vec[i].pb(x);
}
}
set<pii>interval;
for(int i=1;i<=q;i++){
ll l = 1;
vector<ll>suff(vec[i].size() + 5);
for(int j=vec[i].size();j>=0;j--){
if(j == vec[i].size()-1) suff[j] = vec[i][j];
else suff[j] = suff[j+1] + vec[i][j];
}
for(int j=0;j<vec[i].size();j++){
ll val = max(0LL, 2*vec[i][j] - (n-(j == vec[i].size()-1 ? 0 : suff[j+1])-l+1));
if(val > 0) interval.insert({l-val+vec[i][j], l+vec[i][j]-1});
l += vec[i][j];
}
}
if(interval.size() == 0){
cout << 0 << endl;
continue;
}
ll last = -1, prev = -1, mx = 0, ans = 0;
for(auto i : interval){
if(prev == -1) prev = i.fi;
if(i.fi != prev){
ans += max(0LL, last - max(prev - 1,mx));
mx = max(mx, last);
prev = i.fi;
last = 0;
}
last = i.sec;
}
ans += max(0LL, last - max(prev - 1,mx));
cout << ans << endl;
}
}
/*
1 2 3 4 5 6 7 8 9 10 11
*/컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
