답안 #1094254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094254 2024-09-29T08:25:41 Z akim9905 Naan (JOI19_naan) C++17
24 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

#define fileio() freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define allr(x) x.rbegin(), x.rend()
#define cmprs(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define endl "\n"
#define sp " "
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define rz resize
#define sz(a) (int)(a.size())
#define clr(a) a.clear()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef tuple<int, int, int> tpi;
typedef tuple<ll, ll, ll> tpl;
typedef pair<double, ll> pdl;
typedef pair<double, int> pdi;

const int dx[] = {1,-1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MAX = 2020; // PLZ CHK!

int N,L,V[MAX][MAX],P[MAX][MAX];

int chk[MAX];
double avg[MAX];

int main() {
    fio();
    cin>>N>>L;
    for (int i=1; i<=N; i++) {
        for (int j=1; j<=L; j++) {
            cin>>V[i][j];
            P[i][j]=P[i][j-1]+V[i][j];
            avg[i]+=V[i][j];
        }
        avg[i]/=N;
    }

    const double eps=1e-9;
    vector<int> per;

    double cur=0.0;
    vector<pair<double,int>> ans;
    for (int d=1; d<=N && cur+eps<L; d++) {
        vector<pair<double,int>> nxts;
        int curc=(int)ceil(cur);
        for (int i=1; i<=N; i++) {
            if (chk[i]) continue;

            double le=cur,ri=L,nxt=L;
            for (int t=0; t<50; t++) {
                double md=(le+ri)/2.0;

                double cal=0.0;
                int mdf=(int)floor(md),mdc=(int)ceil(md);
                cal+=1.0*(curc-cur)*V[i][curc];
                cal+=P[i][mdf]-P[i][curc];
                cal+=(md-mdf)*V[i][mdc];

                if (avg[i]<=cal) {
                    ri=md;
                    nxt=md;
                }
                else le=md;
            }
            
            double res=0.0;
            int ntf=(int)floor(nxt),ntc=(int)ceil(nxt);
            res+=1.0*(curc-cur)*V[i][curc];
            res+=P[i][ntf]-P[i][curc];
            res+=(nxt-ntf)*V[i][ntc];

            if (avg[i]-eps<res) {
                if (d==N) nxt=L;
                nxts.pb({nxt,i});
            }
        }   

        if (nxts.empty()) {
            cout<<-1;
            return 0;
        }

        sort(all(nxts));
        ans.pb({nxts[0].F-cur,nxts[0].S});
        cur=nxts[0].F;
        chk[nxts[0].S]=1;
    }

    double seg=0.0;
    for (int i=0; i<N-1; i++) {
        auto [a,b]=ans[i];
        seg+=a;
        ll p=seg*1e9, q=1e9;
        cout<<p<<sp<<q<<endl;   
    }
    for (auto [a,b]:ans) cout<<b<<sp;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Integer parameter [name=A_i] equals to -1, violates the range [1, 2000000000000]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 360 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 476 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Integer parameter [name=A_i] equals to -1, violates the range [1, 2000000000000]
12 Halted 0 ms 0 KB -