답안 #1085390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085390 2024-09-08T07:44:51 Z _rain_ Arcade (NOI20_arcade) C++14
0 / 100
1000 ms 152916 KB
#include<bits/stdc++.h>
using namespace std;

#define fixbug true
#define ll long long

const int maxm = 5e5;
#define ii pair<int,int>
#define fi first
#define se second
ii a[maxm+2];
int n , m;

namespace subtask1{
    bool check(){
        return n <= 100 && m <= 100;
    }
    set<vector<ii>> used;
    int best = (int)1e9+7;
    void recur(int idx , vector<ii> arms){
        if (idx==m+1){
            best = min(best , (int)arms.size());
            return;
        }
        if (used.find(arms)!=used.end()) return;
        used.insert(arms);
        for (auto& x : arms){

            if (abs(x.second - a[idx].second) <= a[idx].first - x.first){
                ii old = x;
                x = a[idx];
                recur(idx+1,arms);
                x = old;
            }
        }
        arms.push_back(a[idx]);
        recur(idx+1,arms);
    }
    void main_code(){
        vector<ii> arms;
        sort(a+1,a+m+1);
        recur(0,arms);
        cout << best;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #define name "main"
    if (fopen(name".inp","r")){
        freopen(name".inp","r",stdin);
        freopen(name".out","w",stdout);
    }

    cin >> n >> m;
    for (int i = 1; i <= m; ++i) cin >> a[i].fi;
    for (int i = 1; i <= m; ++i) cin >> a[i].se;
    if (subtask1::check()) {
        subtask1::main_code();
        exit(0);
    }
}

Compilation message

Arcade.cpp: In function 'int main()':
Arcade.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen(name".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Arcade.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen(name".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1109 ms 152916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1109 ms 152916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1109 ms 152916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1109 ms 152916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1109 ms 152916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1109 ms 152916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1109 ms 152916 KB Time limit exceeded
2 Halted 0 ms 0 KB -