Submission #320606

# Submission time Handle Problem Language Result Execution time Memory
320606 2020-11-09T08:39:54 Z teehandsome Just Long Neckties (JOI20_ho_t1) C++11
9 / 100
1000 ms 7448 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {for(auto e:x) cerr<<e<<",";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

int n;
vector<int> a;
vector<int> b;

int solve(int x) {
    vector<int> ar;
    for(int i=0;i<=n;i++) {
        if(i!=x) ar.push_back(a[i]);
    }
    sort(all(ar));
    int mx=0;
    for(int i=0;i<n;i++) {
        int temp=max(0,ar[i]-b[i]);
        mx=max(mx,temp);
    }
    return mx;
}

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n; a.resize(n+1); b.resize(n);
    for(int i=0;i<=n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
    for(int i=0;i<=n;i++) {
        cout<<solve(i)<<' ';
    }
    cout<<endl;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:51:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   51 |     for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
      |     ^~~
ho_t1.cpp:51:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |     for(int i=0;i<n;i++) cin>>b[i]; sort(all(b));
      |                                     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 28 ms 364 KB Output is correct
15 Correct 90 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 154 ms 484 KB Output is correct
18 Correct 112 ms 616 KB Output is correct
19 Correct 117 ms 484 KB Output is correct
20 Correct 113 ms 492 KB Output is correct
21 Correct 118 ms 484 KB Output is correct
22 Correct 110 ms 480 KB Output is correct
23 Correct 111 ms 364 KB Output is correct
24 Correct 121 ms 364 KB Output is correct
25 Correct 177 ms 612 KB Output is correct
26 Correct 158 ms 484 KB Output is correct
27 Correct 150 ms 484 KB Output is correct
28 Correct 179 ms 488 KB Output is correct
29 Correct 129 ms 484 KB Output is correct
30 Correct 152 ms 488 KB Output is correct
31 Correct 176 ms 484 KB Output is correct
32 Correct 193 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 28 ms 364 KB Output is correct
15 Correct 90 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 154 ms 484 KB Output is correct
18 Correct 112 ms 616 KB Output is correct
19 Correct 117 ms 484 KB Output is correct
20 Correct 113 ms 492 KB Output is correct
21 Correct 118 ms 484 KB Output is correct
22 Correct 110 ms 480 KB Output is correct
23 Correct 111 ms 364 KB Output is correct
24 Correct 121 ms 364 KB Output is correct
25 Correct 177 ms 612 KB Output is correct
26 Correct 158 ms 484 KB Output is correct
27 Correct 150 ms 484 KB Output is correct
28 Correct 179 ms 488 KB Output is correct
29 Correct 129 ms 484 KB Output is correct
30 Correct 152 ms 488 KB Output is correct
31 Correct 176 ms 484 KB Output is correct
32 Correct 193 ms 484 KB Output is correct
33 Execution timed out 1092 ms 7448 KB Time limit exceeded
34 Halted 0 ms 0 KB -