惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Last Watchdog
The Last Watchdog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
C
Check Point Blog
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
S
Security @ Cisco Blogs
IT之家
IT之家
T
The Exploit Database - CXSecurity.com
The GitHub Blog
The GitHub Blog
D
Docker
Engineering at Meta
Engineering at Meta
AWS News Blog
AWS News Blog
S
Security Affairs
U
Unit 42
P
Palo Alto Networks Blog
V
Visual Studio Blog
Y
Y Combinator Blog
D
DataBreaches.Net
Forbes - Security
Forbes - Security
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
Security Latest
Security Latest
aimingoo的专栏
aimingoo的专栏
Simon Willison's Weblog
Simon Willison's Weblog
A
Arctic Wolf
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hacker News: Front Page
博客园 - 司徒正美
博客园 - Franky
宝玉的分享
宝玉的分享
TaoSecurity Blog
TaoSecurity Blog
Latest news
Latest news
Scott Helme
Scott Helme
MongoDB | Blog
MongoDB | Blog
量子位
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cisco Blogs
P
Privacy International News Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - y丶innocence

临时111 RecyclerView 数据多时无法滑动:ConstraintLayout 约束高度修复笔记 Android Kotlin OkHttp3 WebSocket 长连接与 Gson 数据解析系统笔记 Android + Kotlin + OkHttp WebSocket 相关概念与使用流程笔记(TLS/证书 + 鉴权/会话) AI对话导出markdown格式流程 代理转发 分享文件 面向全球的app的excel导出和kotlin IO原理 安卓导出笔记(未整理) java&kotlin listener 0.7 动画 0.4 View 工作流程 0.3 view 滑动冲突 13. Jetpack 0. 安卓开发艺术探索参考资料 12. Material Design 7. 持久化技术 5. Fragment java 基础 4. UI 开发 3. Activity 2.2 Kotlin 面向对象 2.3 Kotlin高级 2.1 Kotlin基础 1. Android简介 [OpenJudge] 反正切函数的应用 (枚举)(数学)
[OpenJudge] 摘花生 (模拟)
y丶innocence · 2017-01-23 · via 博客园 - y丶innocence
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[60][60],sumt[2510]={0},sum[2510]={0};
struct Peanut{
    int x,y,s;
};
struct sortf{
    bool operator()(const Peanut &a,const Peanut &b){
        return a.s>b.s;
    }
};

Peanut f[2510];
int main()
{
    int w;
    cin >> w;
    while(w--){
        memset(a,0,sizeof(a));
        int m,n,k,ii=0;
        cin >> m >> n >> k;
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                cin >> a[i][j];
                if(a[i][j]>0) {
                    ii++;
                    f[ii].s=a[i][j];
                    f[ii].x=i;
                    f[ii].y=j;
                }
            }
        }
        sort(f+1,f+1+ii,sortf());
        
        int x=0,y=f[1].y;
        int t=0;
        for(int i=1;i<=ii;i++){
            t=t+abs(x-f[i].x)+abs(y-f[i].y)+1;
            sumt[i]=t+f[i].x;
            sum[i]=sum[i-1]+f[i].s;
            x=f[i].x;y=f[i].y;
            if(k<sumt[i]){
                cout << sum[i-1];
                break;
            }
            if(i==ii&&k>=sumt[ii]) cout << sum[i];
        }
        cout << endl;
    }
    return 0;
}