1:#include <string> 2:#include <vector> 3:#include <fstream> 4:#include <iomanip> 5:#include <iostream> 6:#include <algorithm> 7: 8:using namespace std; 9: 10:#define PROB_NAME "C" 11: 12:bool duringnight (int b, int e) // [b,e) 13:{ 14: b %= 24 * 60; e %= 24 * 60; 15: if (0 <= b && b < 6 * 60 + 1) return true; // Rules are not clear about the length 16: if (0 < e && e <= 6 * 60 + 1) return true; // of night. Is it 6 hours or 361 minutes? 17: return false; 18:} 19: 20:int main () 21:{ 22: ifstream fin (PROB_NAME ".in"); 23: 24: while (0 == 0) 25: { 26: vector<string> name; 27: vector<int> length, minute; 28: 29: string foo; 30: while ((fin >> foo) && foo != "$" && foo != "--") 31: { 32: name.push_back (foo); length.push_back (-1); minute.push_back (-1); 33: fin >> length.back() >> minute.back(); 34: } 35: if (foo == "--") break; 36: 37: string stname, enname; 38: int sth = -1, stm = -1; 39: char bar; 40: 41: fin >> stname >> enname >> sth >> bar >> stm; 42: fin >> foo; 43: 44: int st = int(find(name.begin(), name.end(), stname) - name.begin()); 45: int en = int(find(name.begin(), name.end(), enname) - name.begin()); 46: 47: int stt = (sth * 60 + stm) % (24 * 60); 48: int curt = stt; 49: int totallen = 0; 50: double fare = 0.0; 51: for (int i = st; i <= en; ++i) 52: { 53: for (int j = 0; j < length[i]; ++j) 54: { 55: bool night = duringnight (curt, curt + minute[i]); 56: double rate = (night ? 1.2 : 1.0); 57: 58: if (totallen < 10) fare += 1000 * rate; 59: else if (totallen < 30) fare += 250 * rate; 60: else fare += 100 * rate; 61: 62: totallen++; 63: curt += minute[i]; 64: } 65: } 66: double avgkph = totallen / (60 * (curt - stt)); 67: if (avgkph < 30) fare *= 1.1; 68: 69: cout << fare << endl; 70: } 71: return 0; 72:} 73:
Tuesday, December 19, 2006
Sharif ICPC Regionals 2006 - Problem C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment