当前位置:网站首页>202012 CCF test questions
202012 CCF test questions
2022-06-13 09:07:00 【antRain】
202012 CCF test questions
202012-1 Safety index of final forecast
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define debug
int main(){
#ifdef debug
freopen("test.in", "r", stdin);
#endif
int n,w,s;
cin>>n;
ll sum=0;
for(int i=0;i<n;++i){
cin>>w>>s;
sum += w*s;
// cout<<sum<<endl;
}
cout << ((sum > 0)?sum:0);
}
202012-2 The best threshold of final forecast

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5 ;
// #define debug
struct Predict{
int y;
int r;
int n0; // Statistics 0 The number of
int n1; // Statistics 1 The number of
Predict(int y=0,int r=0,int n0=0,int n1=0):y(y),r(r),n0(n0),n1(n1){
}
void setn(int n0,int n1){
this->n0 = n0;
this->n1 = n1;
}
};
bool cmp(const Predict& a, const Predict& b)
{
return a.y < b.y; // Sort from large to small
}
Predict pred[MAXN];
/* According to the general meaning of the topic , First count each number ( It's going to repeat itself ) Marked as 0,1 The number of , Then give a number , Find the sign less than this number 0 The number of and greater than or equal to are marked as 1 Number of numbers It is equivalent to dividing into two sections , Left side , Cumulative value on the right , For accumulation, we can use prefix and to do so : Prioritize , duplicate removal , Find the prefix and , Find the result */
int main(){
#ifdef debug
// freopen("test.in", "r", stdin); // 3
freopen("test1.in", "r", stdin); // 100000000
// freopen("test.out","w", stdout);
#endif
int m,tmp=1,result = 0,maxr=0;
cin>>m;
for(int i=1;i<=m;++i){
cin>>pred[i].y>>pred[i].r;
if(pred[i].r==1) {
pred[i].setn(0,1);
} else {
pred[i].setn(1,0);
}
}
// m++;
sort(pred+1,pred+m+1,cmp);
// duplicate removal
for(int i=2;i<=m;++i) {
if(pred[i].y==pred[i-1].y){
pred[tmp].n1 += pred[i].n1;
pred[tmp].n0 += pred[i].n0;
} else {
pred[++tmp].y = pred[i].y;
pred[tmp].n1 = pred[i].n1;
pred[tmp].n0 = pred[i].n0;
}
}
m = tmp;
for(int i=1;i<=m;++i){
pred[i].n0 += pred[i-1].n0;
pred[i].n1 += pred[i-1].n1;
}
for (int i=1;i<=m;++i){
tmp = pred[i-1].n0 + pred[m].n1 - pred[i-1].n1; // Duplicate data
// cout<<tmp<<endl;
if (tmp>=maxr) {
maxr = tmp;
result = pred[i].y;
}
}
cout<<result;
}
边栏推荐
- pytorch相同结构不同参数名模型加载权重
- CAS NO lock
- JUC atomic reference and ABA problem
- Tutorial (5.0) 01 Product introduction and installation * fortiedr * Fortinet network security expert NSE 5
- CAS无锁
- 如何成为白帽子黑客?我建议你从这几个阶段开始学习
- JUC 字段更新器
- 教程篇(5.0) 02. 管理 * FortiEDR * Fortinet 网络安全专家 NSE 5
- 20211115 任意n阶方阵均与三角矩阵(上三角或者下三角)相似
- What are the bank financial products? How long is the liquidation period?
猜你喜欢

网络安全漏洞分析之重定向漏洞分析

Simulink如何添加模块到Library Browser

Jfinal and swagger integration

The Jenkins console does not output custom shell execution logs

transforms. ColorJitter(0.3, 0, 0, 0)

Onnx crop intermediate node

Completely uninstall PostgreSQL under Linux

Simulink的Variant Model和Variant Subsystem用法

Message Oriented Middleware

Qvector shallow copy performance test
随机推荐
20211104 为什么矩阵的迹等于特征值之和,为什么矩阵的行列式等于特征值之积
Neo4j环境搭建
20220606 关于矩阵的Young不等式
20211115 任意n阶方阵均与三角矩阵(上三角或者下三角)相似
14. class initialization, default constructor, =default
redis 模糊查询 批量删除
transforms. ColorJitter(0.3, 0, 0, 0)
An error CV2 is reported when the picture is converted to grayscale cvtColor(img, cv2.COLOR_BGR2GRAY)
JUC 字段更新器
20211005 Hermite matrix and some properties
How to become a white hat hacker? I suggest you start from these stages
消息中间件
What are the bank financial products? How long is the liquidation period?
教程篇(5.0) 02. 管理 * FortiEDR * Fortinet 网络安全专家 NSE 5
Cesium achieves sunny, rainy, foggy, snowy and other effects
20211108 observable, controllable, stable and measurable
【安全】零基础如何从0到1逆袭成为安全工程师
教程篇(5.0) 03. 安全策略 * FortiEDR * Fortinet 网络安全专家 NSE 5
""? "& in URL Role of "" sign
A very detailed blog about the implementation of bilinear interpolation by opencv