제출 #736178

#제출 시각아이디문제언어결과실행 시간메모리
736178onebit1024Lasers (NOI19_lasers)C++17
0 / 100
42 ms13400 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define all(c) c.begin(), c.end() #define endl "\n" const double PI=3.141592653589; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define dbg(x...) cerr << "LINE(" << __LINE__ << ") -> " <<"[" << #x << "] = ["; _print(x) #else #define dbg(x...) #endif void solve() { int L,n; cin >> L >> n; vector<pair<int,int>>tot; for(int i = 1;i<=n;++i){ int x; cin >> x; vector<int>a(x+1); int sum = 0; for(int j= 1;j<=x;++j)cin >> a[j],sum+=a[j]; int space = L-sum; sum = 0; int curr = 1; vector<pair<int,int>>range; for(int j = 1;j<=x;++j){ if(space)range.pb({curr,curr+space-1}); sum+=a[j]; curr = sum+1; } if(space)range.pb({curr,L}); vector<pair<int,int>>not_safe; for(int j = 1;j<(int)(range.size());++j){ if(range[j].first > range[j-1].second+1)not_safe.pb({range[j-1].second+1,range[j].first-1}); } for(auto x : not_safe)tot.pb(x); } sort(all(tot)); int res = 0; int r = 1; if(!tot.empty())r = tot[0].second, res+= (tot[0].second-tot[0].first+1); for(int j = 1;j<(int)(tot.size());++j){ if(tot[j].second > r){ res+=tot[j].second-max(r+1,tot[j].first)+1; } r = max(r, tot[j].second); } cout << res << endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int T=1; for(int i = 1;i<=T;++i) { // cout << "Case #" << i << ": "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...