Submission #1130164

#TimeUsernameProblemLanguageResultExecution timeMemory
1130164ByeWorldA Difficult(y) Choice (BOI21_books)C++20
0 / 100
1 ms428 KiB
#include <bits/stdc++.h>

#include "books.h"

#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<int,pii> ipii;
typedef pair<pii,pii> ipiii;
const int MAXN = 1e5+20;
const int MAXA = 1e6;
const int INF = 1e18+10;
const int MOD = 1e9+7;
const int LOG = 32;
const ld EPS = 1e-12;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
//     books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ books_sample.cpp sample_grader.cpp
// in this folder.
//

int n, query, num;
ll a;
map<ll,int> m;

ll que(int x){
	if(m.find(x) == m.end()){
		m[x] = skim(x); 
	}
	return m[x];
}
void solve(int N, int K, long long A, int S) {
	n = N, num = K, a = A; query = S;
    // TODO implement this function
    for(int i=1; i<=n; i++) que(i);

    set <pii> s;
	for(int i=1; i<=n; i++) s.insert({m[i], i});
    for(int i=1; i<=n-num+2; i++){
    	ll te = 0;
    	for(int j=i; j<=i+num-2; j++) te += que(j), s.erase(pii(m[j],j));
    	auto it = s.lower_bound(pii(a-te, -1));

    	if(it!=s.end() && te+(*it).fi <= 2*a){
    		vector<int>vec;
    		for(int j=i; j<=i+num-2; j++) vec.pb(j);
    		vec.pb((*it).se);
    		answer(vec);
    	}

    	for(int j=i; j<=i+num-2; j++) s.insert(pii(m[j],j));
    }
	impossible();
}

Compilation message (stderr)

books.cpp:20:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   20 | const int INF = 1e18+10;
      |                 ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...