青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

O(1) 的小樂

Job Hunting

公告

記錄我的生活和工作。。。
<2010年9月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

統計

  • 隨筆 - 182
  • 文章 - 1
  • 評論 - 41
  • 引用 - 0

留言簿(10)

隨筆分類(70)

隨筆檔案(182)

文章檔案(1)

如影隨形

搜索

  •  

最新隨筆

最新評論

閱讀排行榜

評論排行榜

SRM 481

Div2

1 比較簡單的一道題目,理清楚邏輯關系。。

2 trick的一道題目,真是惡心人啊。。。從下面的一張圖中來看出種種的關系。。比賽的時候,糾結了。。所以沒搞出來。。

In the graphic, c + y will be equal to x (The total number of people that told you the correct answer) and a+b will be equal to n-x (The total number of people that told you the wrong answer). Since we know the number of elements in LIARS (liarCount) and the number of people in the intersection is assumed to be y we can conclude that a=lieCount-y. Similarly, b = liarCount-y. Since all the other literals are known, c = n - a - b - y. Knowing a, b, c and y we can verify: If (a+b) is equal to (n-x) and (c+y = x) then the scenario is possible. There is an implicit condition, an important one that was missed by many during the match, we do not want y to be so small, that the sum a+b-y is larger than n, this case can be detected by making sure that c is positive. Also note that since the numbers in the input can only be as large as 1000000, we can simply iterate through all the possible values of y until one for which the previous conditions hold.
We can then code a solution:

// Is the following scenario possible?:
//
// n people.
// x people told the truth.
// lieCount people were lied to.
// liarCount people lied intentionally
//
boolean check(int n, int x, int lieCount, int liarCount) {
    // Iterate through all the possible values of the intersection y:
    for (int y = 0; y <= lieCount && y <= liarCount; y++) {
        int a = lieCount - y;
        int b = liarCount - y;
        int c = n - a - b - y;

        // Do all the required conditions hold?
        if ( a+b==n-x && c+y==x && c>=0 ) {
            return true;
        }
    }
    return false;
}
//

public String theTruth(int n, int eggCount, int lieCount, int liarCount) {
    // Call the sub-routine, first assuming that the egg is the correct answer
    boolean egg =     check(n,eggCount, lieCount, liarCount );
    // Then assuming that the chicken is the correct answer:
    boolean chicken = check(n,n-eggCount, lieCount, liarCount );
    if(egg&&chicken) {
        return "Ambiguous";
    } else if (egg) {
        return "The egg";
    } else if (chicken) {
        return "The chicken";
    } else {
        return "The oracle is a lie";
    }
}
 

其中的邏輯關系還是很顯然的。。要淡定!。。。

QQ截圖未命名

看看某個房間里的情況。。唉,這告訴我們無論什么時候都不要放棄努力!

仔細和認真,有一個端正的態度是做好一切事情的法寶!

3 這個第三題應當和第二題換一下啊。。非常簡單。。

  因為一個人可能會有幾個job,但是一個job只能對應于一個人。。這就使問題變得非常簡單了。。很easy的會想到每個人的job duration和來做排序。。如果job duration 和相同,就以第一個首元素做排序標準。。

map <string,int> mp;
struct str{
       long long tot;
       int num;
       int next[55];
};
str st[55];
bool operator <(str a, str b)
{
     if (a.tot != b.tot)
        return a.tot < b.tot;
     return a.next[0] < b.next[0];
}
class BatchSystem
{
        public:
        vector <int> schedule(vector <int> duration, vector <string> user)
        {
               int n = duration.size();
               int i,j,t;
               int ct = 0;
               memset(st,0,sizeof(st));
               mp.clear();
               for (i = 0;i < n;i++)
               {
                   if (mp.find(user[i]) == mp.end())
                      mp[user[i]] = ct++;
                   t = mp[user[i]];
                   st[t].tot += duration[i];
                   st[t].next[st[t].num++] = i;
               }
               sort(st,st + ct);
               vector <int> ans;
               ans.clear();
               for (i = 0;i < ct;i++)
               {
                   for (j = 0;j < st[i].num;j++)
                       ans.push_back(st[i].next[j]);
               }
               return ans;
        }
};

剛開始的時候,以為這個題目中,一個job可以對應于幾個人的情況。。實在是不應該啊。。

 

 

 

===========================================================================================

不是很華麗的分割線。。。

===========================================================================================

DIV1

1 DIV2 500的題目,照例的惡心。。。

2 基于DIV900的那個理論,然后這次是求期望等待時間,需要分階段來討論。首先是在此人之前的人,其次是具有相同優先級的人,再次是這個人的不同工作之間。??傊?,也是一個比較簡單的題目。

vector <double> expectedFinishTimes(vector <int> duration, vector <string> user)
{
    int n = duration.size();
    // Find users and their total durations:
    map<string, long long> userDuration;
    for (int i=0; i<n; i++) {
        userDuration[user[i]]+=duration[i];
    }
    vector<double> res(n);
    for (int i=0; i<n; i++) {
        int eqn = 0;
        double before = 0;
        // For each pair user, total duration:
        //   * count the number of users with the same
        //     total duration (eqn).
        //   * Accumulate the total duration from users
        //     with smaller total duration (before).
        for ( map<string,long long>::iterator it = userDuration.begin();
              it!=userDuration.end(); it++) {

            if (it->second < userDuration[user[i]] ) {
                before += it->second;
            } else if ( it->second == userDuration[user[i]] ) {
                eqn ++;
            }
        }
        // The time this process will have to wait is:
        //  before :
        //      The waiting time caused by users with lower total durations.
        // + (eqn-1) * userDuration[user[i]] / 2.0 :
        //      The expected waiting time caused by users with the same total duration.
        //
        // + (userDuration[user[i]]-duration[i]) / 2.0 :
        //      The expected waiting time caused by jobs from the same user.
        //
        // + duration[i]:
        //      The job's duration
        res[i] = before
                 + (eqn-1) * userDuration[user[i]] / 2.0
                 + (userDuration[user[i]]-duration[i]) / 2.0
                 + duration[i];
    }
    return res;
}
 
3 忘了什么意思了。。有時間貼出來。
Reference : 參考了SRM 481的解題報告和 best solution。。。代碼都是大大們寫的。。。學習!
 

posted on 2010-09-12 17:41 Sosi 閱讀(280) 評論(0)  編輯 收藏 引用

統計系統
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产精品99久久久久久www| 欧美在线一区二区| 亚洲影视综合| 亚洲自拍电影| 欧美伊人久久| 久久综合成人精品亚洲另类欧美 | 久久深夜福利免费观看| 性色av香蕉一区二区| 午夜精品久久久久久久99热浪潮| 亚洲欧美日韩高清| 久久国产日本精品| 欧美华人在线视频| 国产精品豆花视频| 国产精品亚洲不卡a| 亚洲制服丝袜在线| 久久久免费av| 欧美精品一区二区高清在线观看| 欧美午夜宅男影院在线观看| 国产日韩精品综合网站| 在线高清一区| 一本色道久久综合亚洲精品高清| 欧美在线一区二区| 亚洲第一区在线观看| 亚洲国产精品一区二区三区| 亚洲午夜视频在线| 美女精品在线观看| 国产精品日韩| 日韩亚洲一区二区| 久久精品国内一区二区三区| 亚洲国产天堂久久综合网| 亚洲一区精品电影| 欧美岛国激情| 在线观看日韩av电影| 亚洲免费在线电影| 欧美福利视频| 欧美在线看片| 国产精品久久久久秋霞鲁丝 | 亚洲国产成人午夜在线一区| 亚洲综合色自拍一区| 免费在线成人| 国产一二三精品| 亚洲欧美日韩精品久久亚洲区| 免费一级欧美片在线观看| 亚洲影视综合| 欧美色精品在线视频| 亚洲二区免费| 久久精品国产一区二区三| 亚洲视频免费看| 欧美日韩国产大片| 亚洲日本va午夜在线电影| 久久综合激情| 欧美在线视频导航| 国产日韩专区| 欧美专区日韩视频| 亚洲在线国产日韩欧美| 欧美性理论片在线观看片免费| 亚洲精品在线一区二区| 免费中文字幕日韩欧美| 欧美一区二区女人| 久久久www成人免费无遮挡大片| 激情视频亚洲| 伊人春色精品| 久久久久久精| 欧美一区二区女人| 黄色一区二区三区四区| 欧美在线一级va免费观看| 一二三区精品| 国产精品日韩欧美一区二区三区| 亚洲一区日本| 亚洲欧美国产日韩天堂区| 国产欧美亚洲视频| 欧美一区二区视频97| 亚洲欧美一级二级三级| 国产日韩在线看片| 久久久一二三| 浪潮色综合久久天堂| 亚洲精品一区二区三区四区高清| 亚洲国产精品久久久久| 欧美激情区在线播放| 亚洲淫性视频| 欧美一区激情| 最新国产拍偷乱拍精品 | 亚洲精品日韩精品| 亚洲精品一区二区三区av| 欧美日韩mp4| 亚洲欧美综合| 久久综合狠狠综合久久激情| 日韩网站在线看片你懂的| 亚洲精品午夜| 国产日韩欧美精品在线| 裸体歌舞表演一区二区| 欧美国产一区二区| 欧美在线免费观看亚洲| 麻豆精品一区二区av白丝在线| 99re亚洲国产精品| 亚洲欧美影音先锋| 亚洲国产美女久久久久| 一区二区三区精品在线| 激情五月***国产精品| 亚洲黄一区二区三区| 国产精品久久一区二区三区| 久久久国产午夜精品| 欧美日本一区二区视频在线观看| 先锋影音久久久| 久热精品视频在线| 欧美一区在线视频| 欧美精品亚洲二区| 免费观看成人| 国产美女精品人人做人人爽| 免费观看一区| 国产亚洲毛片| 中文国产一区| 一区二区三区 在线观看视频| 午夜精品久久久久久久白皮肤| 欧美国产日韩精品| 久久在线精品| 国产精品一区二区久久精品| 亚洲国产精品日韩| 国产一区在线播放| 一本色道久久综合狠狠躁的推荐| 国产精品免费久久久久久| 亚洲开发第一视频在线播放| 国产精品亚洲一区| 亚洲电影av| 欧美与黑人午夜性猛交久久久| 亚洲精品三级| 久久久无码精品亚洲日韩按摩| 亚洲午夜女主播在线直播| 狂野欧美一区| 久久综合婷婷| 狠狠色丁香婷综合久久| 亚洲一区二区免费视频| 99热在线精品观看| 欧美风情在线观看| 男女精品网站| 亚洲国产高清在线观看视频| 久久久久久一区二区三区| 久久电影一区| 国产一区亚洲| 久久久另类综合| 久热精品视频在线观看一区| 国产日韩欧美综合| 亚洲欧美精品在线观看| 久久精品一本久久99精品| 国产亚洲精品自拍| 久久精品中文字幕免费mv| 久久精品视频免费| 黄色成人av在线| 久热成人在线视频| 亚洲人成网站在线观看播放| 亚洲免费福利视频| 欧美日韩一区免费| 亚洲桃花岛网站| 欧美在线一级va免费观看| 国产综合一区二区| 美腿丝袜亚洲色图| 亚洲国产一区二区视频| 一区二区久久久久久| 欧美午夜宅男影院在线观看| 久久人人爽爽爽人久久久| 亚洲精品国产精品国产自| 欧美日韩成人综合天天影院| 99视频精品| 久久九九99视频| 亚洲高清自拍| 欧美日韩国产精品成人| 亚洲午夜羞羞片| 久久一区二区三区超碰国产精品| 亚洲精品1234| 国产精品三级视频| 亚洲线精品一区二区三区八戒| 国产精品美腿一区在线看| 久久精品视频在线| 亚洲国产日韩欧美一区二区三区| 亚洲午夜精品久久久久久app| 国产精品亚洲网站| 欧美精品久久99| 欧美一区二区三区视频| 亚洲国产欧美一区二区三区同亚洲| 亚洲一本大道在线| 在线日韩成人| 国产精品久久久久久久久搜平片 | 国产精品女人网站| 久久亚洲精品视频| 欧美亚洲第一区| 99国产精品久久久久久久久久| 久久国产日韩| 夜夜嗨网站十八久久| 红桃视频国产精品| 国产精品国码视频| 欧美成人国产| 欧美一进一出视频| 日韩视频不卡| 欧美福利一区二区| 亚洲第一精品在线| 国产欧美日韩综合一区在线播放| 免费欧美在线视频| 久久精品免费电影| 亚洲欧美精品在线| 亚洲天堂偷拍|