답안 #462270

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
462270 2021-08-10T09:21:42 Z idas Exam (eJOI20_exam) C++11
12 / 100
28 ms 1476 KB
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SZ(x) ((int)((x).size()))
#define LE(vec) vec[vec.size()-1]
#define TSTS int t; cin >> t; while(t--)solve()

const int INF = 1e9;
const long long LINF = 1e18;
const long double PI = asin(1)*2;
const int MOD = 1e9+7;

using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef long long ll;
typedef long double ld;

void setIO()
{
    FAST_IO;
}

void setIO (string s)
{
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}

const int N=1e5+10;
int n, a[N], b[N];
bool v[N];

int main()
{
    setIO();
    cin >> n;
    FOR(i, 0, n) cin >> a[i];
    FOR(i, 0, n) cin >> b[i];
    int k=b[0];
    vi ins;
    FOR(i, 0, n)
    {
        if(a[i]==k){
            ins.PB(i);
        }
    }

    for(auto i : ins){
        int j=i;
        v[j]=true;
        while(j+1<n && !v[j+1] && a[j+1]<=k){
            j++;
            v[j]=true;
        }
        while(i-1>=0 && !v[i-1] && a[i-1]<=k){
            i--;
            v[i]=true;
        }
    }

    int cnt=0;
    FOR(i, 0, n) if(v[i]) cnt++;
    cout << cnt;
}

Compilation message

exam.cpp: In function 'void setIO(std::string)':
exam.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exam.cpp:33:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 6 ms 460 KB Output is correct
3 Correct 18 ms 992 KB Output is correct
4 Correct 15 ms 1100 KB Output is correct
5 Correct 28 ms 1180 KB Output is correct
6 Correct 16 ms 1476 KB Output is correct
7 Correct 19 ms 1228 KB Output is correct
8 Correct 26 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -