Submission #58284

# Submission time Handle Problem Language Result Execution time Memory
58284 2018-07-17T10:50:19 Z okaybody10 허수아비 (JOI14_scarecrows) C++
15 / 100
4000 ms 6968 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main()
{
    int n; scanf("%d",&n);
    pii v[200007];
    for(int i=0;i<n;i++) scanf("%d %d",&v[i].first,&v[i].second);
    sort(v,v+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        stack<int> down,up;
        int y=v[i].second;
        for(int j=i+1;j<n;j++)
        {
            int y1=v[j].second;
            if(y<y1)
            {
                if(up.size()==0) up.push(y1);
                else if(up.top()>y1) up.push(y1);
            }
        }
        ans+=down.size();
        ans+=up.size();
    }
    return !printf("%d",ans);
}

// 1. 좌표압축
// 2. 세그먼트 트리로 그것보다 큰거과 작은거 관리해주기
// 3. salesman과 동일하게 풀면 될듯

Compilation message

scarecrows.cpp: In function 'int main()':
scarecrows.cpp:6:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf("%d",&n);
            ~~~~~^~~~~~~~~
scarecrows.cpp:8:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%d %d",&v[i].first,&v[i].second);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2040 KB Output is correct
2 Correct 4 ms 2164 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 6 ms 2288 KB Output is correct
5 Correct 5 ms 2480 KB Output is correct
6 Correct 5 ms 2492 KB Output is correct
7 Correct 5 ms 2492 KB Output is correct
8 Correct 5 ms 2492 KB Output is correct
9 Correct 5 ms 2492 KB Output is correct
10 Correct 4 ms 2492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 2652 KB Output is correct
2 Correct 91 ms 2696 KB Output is correct
3 Correct 79 ms 2796 KB Output is correct
4 Correct 64 ms 2892 KB Output is correct
5 Correct 62 ms 2992 KB Output is correct
6 Correct 94 ms 3092 KB Output is correct
7 Correct 77 ms 3192 KB Output is correct
8 Correct 44 ms 3420 KB Output is correct
9 Correct 91 ms 3420 KB Output is correct
10 Correct 74 ms 3492 KB Output is correct
11 Correct 96 ms 3592 KB Output is correct
12 Correct 34 ms 3692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4067 ms 6968 KB Time limit exceeded
2 Halted 0 ms 0 KB -