답안 #652833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
652833 2022-10-24T19:24:27 Z raysh07 Lightning Rod (NOI18_lightningrod) C++14
21 / 100
1427 ms 183080 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void Solve() 
{
    int n;
    cin>>n;
    int x[n];
    int y[n];
    for (int i=0; i<n; i++)
    cin>>x[i]>>y[i];
    
    int c = 0;
    int last = 0;
    int ma = 0;
    int maxi = 0;
    for (int i = 1; i<n; i++)
    {
        if (x[i]-x[last]<=y[i]-y[last])
        {
            if (x[i]+y[i]>=maxi)
            {
                maxi = x[i] + y[i];
                ma = i;
            }
        }
        else 
        {
            c++;
            i--;
            int p = x[ma];
            int q = y[ma];
            maxi = 0;
            for (int j=i; j<n; j++)
            {
                if (x[j]-p<=q-y[j])
                {
                    i = j;
                    last = j+1;
                }
                else break;
            }
        }
    }
    if (last!=n)
    c++;
    cout<<c<<"\n";
}

int32_t main() 
{
    //freopen(".in",  "r", stdin);
    //freopen(".out", "w", stdout);
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++) 
    {
        //cout << "Case #" << i << ": ";
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1292 ms 183080 KB Output is correct
2 Correct 1323 ms 177956 KB Output is correct
3 Correct 1259 ms 166604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1427 ms 167072 KB Output is correct
2 Correct 1313 ms 165432 KB Output is correct
3 Correct 1266 ms 158828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1292 ms 183080 KB Output is correct
2 Correct 1323 ms 177956 KB Output is correct
3 Correct 1259 ms 166604 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -