谁做今晚艺龙笔试题了?请教第二题最小权值,通过率一直14%?

题目确实简单,但是一直告诉我超时通过率为14%,有人和我一样情况吗?或者谁能帮我解答一下原因?
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int k = 0;
    while (k < n)
    {
        int m;
        cin >> m;
        vector<long long> vec(m,99999999);
        vector<char> res(m);
        for (int i = 0; i < m; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                int d = 0;
                scanf("%d", &d);
                if (d < vec[j])
                {
                    vec[j] = d;
                    char c;
                    if (i == 0)
                        res[j] = 'E';
                    else if (i == 1)
                        res[j] = 'S';
                    else if (i == 2)
                        res[j] = 'W';
                    else if (i == 3)
                        res[j] = 'N';
    
                }

            }
        }
        long long sum = 0;
        char *res1 = new char[m];
        for (int j = 0; j < m; ++j)
        {

            sum += vec[j];
            res1[j] = res[j];
        }
        res1[m] = '\0';
        printf("%d\n",sum);
        printf("%s\n",res1);
        k++;
    }
    return 0;
}

全部评论
同14%。
点赞 回复 分享
发布于 2017-09-26 21:30
贼简单
点赞 回复 分享
发布于 2017-09-26 21:39

相关推荐

爱看电影的杨桃allin春招:我感觉你在炫耀
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务