답안 #1007940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007940 2024-06-26T01:24:26 Z kebine Lasers (NOI19_lasers) C++17
10 / 100
39 ms 17404 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pii pair<int,int> 
#define vl vector<ll> 
#define nikah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll maxn = 5e5+7, modn1 = 1e9+7, modn2 = 998244353;
using namespace std;

// kalo kamu ngga emas nanti nadya merasa bersalah, ayo san demi nadya!!!
// Kalo emang soalnya susah, pindah soal dulu 
// Jangan sampe diem, pikirin sesuatu, pasti bisa!!!
// Cobain semua approach, jangan ngestuck di satu pemikiran
// Jangan overthinking, jangan panik, tenangin pikiranmu


ll t,n,q;
ll a[maxn], pref[maxn];
set<pll>s;

void solve () {
  cin>>n>>q;
  while (q--) {
    ll k; cin>>k;
    for (ll i=1; i<=k; i++) {
      cin>>a[i];
      pref[i] = a[i] + pref[i-1];
    }
    ll cnt = 0;
    for (ll i=k; i>=1; i--) {
      ll x = pref[i];
      ll y = n - cnt - a[i] + 1;
      if (x >= y) {
        s.insert({y,x});
      }
      cnt += a[i];
    }
  }
  ll ans = 0, x = 0, y = 0, prey = 0;
  for (auto p : s) {
    x = p.fi; y = p.se;
    if (prey == 0) {
      ans += (y-x+1);
    } else{
      ans += (y - max(prey+1, x) + 1);
    }
    prey = y;
  }
  cout<<ans<<endl;
}           


int main () {
  nikah
  t = 1;
//  cin>>t;
  while (t--) {
    solve();
  //  cout<<endl;
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Incorrect 1 ms 2396 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 17404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 17404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Incorrect 1 ms 2396 KB Output isn't correct
12 Halted 0 ms 0 KB -